Commit graph

758 commits

Author SHA1 Message Date
Paul Gschwendtner
0fb124ad83 build: run ng update for Angular CLI next (#47717)
Runs the Angular CLI v15 migrations for AIO.

PR Close #47717
2022-10-17 12:11:26 +02:00
abergquist
59f3324d6f docs: Separated HTML elements with blank lines (#47331)
Separated HTML elements with judicious use of space. It not only makes it easier to read the HTML; it also makes it consistent with the formatting of https://github.com/angular/angular/edit/main/aio/content/examples/what-is-angular/src/app/hello-world-bindings/hello-world-ngif.component.html.

PR Close #47331
2022-10-13 19:10:27 +00:00
Andrew Kushnir
f73ef21442 feat(router): merge RouterLinkWithHref into RouterLink (#47630)
This commit updates the `RouterLink` to extend the selector to also include `<a>` and `<area>` elements, which were previously matched by the `RouterLinkWithHref` directive. The code of the directives was merged together (since there was a lot of duplication) and this commit finalizes the merge. The `RouterLinkWithHref` becomes an alias of the `RouterLink` directive.

Now there is no need to import and use the `RouterLinkWithHref` class, the `RouterLink` directive will match any element that has the `routerLink` attribute.

DEPRECATED:

The `RouterLinkWithHref` directive is deprecated, use the `RouterLink` directive instead. The `RouterLink` contains the code from the `RouterLinkWithHref` to handle elements with `href` attributes.

PR Close #47630
2022-10-05 15:16:43 -07:00
Alexander Wiebe
89006b1025 fix(docs-infra): add punctuation to dr iq (#47525)
add punctuation to dr iq name to aid in clarity

Fixes #46011

PR Close #47525
2022-09-29 16:43:55 -07:00
Mauro Mattos
ad098d82a8 docs(docs-infra): add missing decorator in tutorial step (#47456)
PR Close #47456
2022-09-19 09:40:12 +02:00
abergquist
678c7f1841 docs: Removed unnecessary blank line (#47329)
PR Close #47329
2022-09-09 14:26:23 -07:00
Marc Wrobel
eca3db5692 docs(docs-infra): fix minor typos in angular.io (#47295) (#47295)
PR Close #47295

PR Close #47295
2022-09-07 10:47:21 -07:00
George Kalpakas
c905da12e2 docs(service-worker): improve docs related to SwUpdate APIs (#46960)
This commit improves documentation related to recently improved or
deprecated `SwUpdate` APIs in the following ways:

- Update [check-for-update.service.ts][1] to make use of the return
  value of [SwUpdate#checkForUpdate()][2].
- Update [prompt-update.service.ts][3] to not call
  [SwUpdate#activateUpdate()][4] and just reload the page.
- Update the [SwUpdate#activateUpdate()][4] API docs to explain that it
  is only useful if you want to update a client without reloading and
  that it can easily lead to version skew.
- Update [a code-snippet][5] to no longer be [hard-coded][6].

[1]: 9d9d05911d/aio/content/examples/service-worker-getting-started/src/app/check-for-update.service.ts (L16)
[2]: https://angular.io/api/service-worker/SwUpdate#checkForUpdate
[3]: 9d9d05911d/aio/content/examples/service-worker-getting-started/src/app/prompt-update.service.ts (L15)
[4]: https://angular.io/api/service-worker/SwUpdate#activateUpdate
[5]: 96c6139c9a/packages/service-worker/src/update.ts (L44-L54)
[6]: https://angular.io/guide/docs-style-guide#hard-coded-snippets

Fixes #43665

PR Close #46960
2022-09-06 09:11:57 -07:00
Roman Matusevich
6277dd70d4 docs: remove duplicated styles (#47143)
PR Close #47143
2022-08-12 18:18:20 +00:00
Roman Matusevich
d4678316b4 docs: fix code samples formatting in tutorial (#47144)
PR Close #47144
2022-08-12 18:17:26 +00:00
Bruno Barbosa
974a71c437 fix(docs-infra): fix nav css on tutorial tour of heroes (#47064)
Fix the navigation button to work properly by the css style applied when the button is active, on tutorial Tour of Heroes.

PR Close #47064
2022-08-08 11:32:40 -07:00
ileil
0920a15139 docs: update dependency injection content (#44466)
Refactored the DI section to improve doc quality, reduce cognitive load and drive consistency.

- Added an overview with prerequisites and doc cards that point to rest of the DI content
- Added introduction topic with topic purpose, value proposition and "fail fast"
- Broke apart complex concepts into simpler tasks
- Unified tone and language for each topic
- Added new content based on SME feedback
- Deleted obsolete content

PR Close #44466
2022-08-05 10:06:13 -07:00
piyush132000
4a68b0f6ab docs: fix code style (#46862)
PR Close #46862
2022-07-18 16:44:20 +00:00
markostanimirovic
b6a950cd60 docs(core): add full example of directive with typed context (#46689)
This commit adds a complete example of a structural directive
with strongly typed context.

PR Close #46689
2022-07-11 20:01:06 +00:00
Aristeidis Bampakos
39c02f1c9d docs(router): mark title strategy as injectable (#46639)
Add the `@Injectable` decorator in the title strategy example so that it can be injected in the providers of the routing module.
PR Close #46639
2022-06-30 12:43:32 -07:00
markostanimirovic
cdd19bd30e docs(core): add full example for IfLoadedDirective (#46425)
This commit adds a full example for the IfLoadedDirective and moves
the code to the StackBlitz playground for structural directives.

Fixes #40739, #37119

PR Close #46425
2022-06-21 11:46:26 -07:00
piyush132000
9ce733aacb docs: fix code style (#45527)
I have removed unnecessary code from the components & i initialize the
form in OnInit function (life cycle). I think initilization of forms and
getting data from service must be done inside ngOnInit.

PR Close #45527
2022-06-14 19:56:49 +00:00
Badawi7
1278d2af6a docs: fix multicast observable example output (#46127)
Fix the order of logs that represent the output of the multicasting example, as the correct behavior is that all observers are notified of the final value before any of them is notified about completion.
PR Close #46127
2022-06-14 17:04:12 +00:00
Andrew Scott
de058bba99 feat(router): Add CanMatch guard to control whether a Route should match (#46021)
Currently we have two main types of guards:
`CanLoad`: decides if we can load a module (used with lazy loading)
`CanActivate` and friends. It decides if we can activate/deactivate a route.
So we always decide where we want to navigate first ("recognize") and create a new router state snapshot. And only then we run guards to check if the navigation should be allowed.
This doesn't handle one very important use case where we want to decide where to navigate based on some data (e.g., who the user is).
I suggest to add a new guard that allows us to do that.

```
[
  {path: 'home', component: AdminHomePage, canUse: [IsAdmin]},
  {path: 'home', component: SimpleHomePage}
]
```

Here, navigating to '/home' will render `AdminHomePage` if the user is an admin and will render 'SimpleHomePage' otherwise. Note that the url will remain '/home'.

With the introduction of standalone components and new features in the Router such as `loadComponent`,
there's a case for deprecating `CanLoad` and replacing it with the `CanMatch` guard. There are a few reasons for this:

* One of the intentions of having separate providers on a Route is that lazy
loading should not be an architectural feature of an application. It's an
optimization you do for code size. That is, there should not be an architectural
feature in the router to specifically control whether to lazy load something or
not based on conditions such as authentication. This is a slight nuanced
difference between the proposed canUse guard: this guard would control whether
you can use the route at all and as a side-effect, whether we download the code.
`CanLoad` only specified whether the code should be downloaded so canUse is more powerful and more appropriate.
* The naming of `CanLoad` will be potentially misunderstood for the `loadComponent` feature.
Because it applies to `loadChildren`, it feels reasonable to think that it will
also apply to `loadComponent`. This isn’t the case: since we don't need
to load the component until right before activation, we defer the
loading until all guards/resolvers have run.

When considering the removal of `CanLoad` and replacing it with `CanMatch`, this
does inform another decision that needed to be made: whether it makes sense for
`CanMatch` guards to return a UrlTree or if they should be restricted to just boolean.
The original thought was that no, these new guards should not allow returning UrlTree
because that significantly expands the intent of the feature from simply
“can I use the route” to “can I use this route, and if not, should I redirect?”
I now believe it should allowed to return `UrlTree` for several reasons:

* For feature parity with `CanLoad`
* Because whether we allow it as a return value or not, developers will still be
able to trigger a redirect from the guards using the `Router.navigate` function.
* Inevitably, there will be developers who disagree with the philosophical decision
to disallow `UrlTree` and we don’t necessarily have a compelling reason to refuse this as a feature.

Relates to #16211 - `CanMatch` instead of `CanActivate` would prevent
blank screen. Additional work is required to close this issue. This can
be accomplished by making the initial navigation result trackable (including
the redirects).
Resolves #14515
Replaces #16416
Resolves #34231
Resolves #17145
Resolves #12088

PR Close #46021
2022-06-13 22:53:49 +00:00
alefra
da8ea7dfaa docs: modify import (#45828)
Modify import after moving Component and Directives

PR Close #45828
2022-06-10 16:11:09 +00:00
alefra
eafe9886b8 docs: move ZippyToggleDirective (#45828)
Move ZippyToggleDirective from app.component.ts

PR Close #45828
2022-06-10 16:11:09 +00:00
alefra
57fa804bb2 docs: remove Component and Directives (#45828)
Move all content to example-zippy.component.ts

PR Close #45828
2022-06-10 16:11:09 +00:00
alefra
008111d2c2 docs: create file to improve docs (#45828)
Move ZippyComponent and ZippyContentDirective to example-zippy.component.ts file to improve readability of the docs

PR Close #45828
2022-06-10 16:11:09 +00:00
dario-piotrowicz
c8086b7e86 docs: make structural directives guide generic (#44895)
tweak the current structural directives guide (currently mainly targeted
at the creation of custom structural directives) so that is more generic
and a point of reference for structural directives in general

this also includes the re-addition of the one-per-element section
removed in PR #40015

resolves #44786

PR Close #44895
2022-05-23 13:44:41 -07:00
Tom Raithel
551671fd51 docs: fix division by zero in progress events example (#46077)
If the `event.total` is undefined, this line would have generated a `NaN` due to division by zero. I suppose, that a `0` would be more suitable for this case.

PR Close #46077
2022-05-23 13:27:45 -07:00
George Kalpakas
67ec9eec64 build(docs-infra): update Angular CLI/framework to v14.0.0-rc.0 in docs examples (#45997)
Update the docs examples to the latest prerelease versions of Angular
CLI and framework (v14.0.0-rc.0).

Also update the example apps to more closely align with new CLI apps.
See also the [diff][1] between a basic v13.0.0-rc.3 CLI app and a
v14.0.0-rc.0 one.

[1]: https://github.com/cexbrayat/angular-cli-diff/compare/13.0.0-rc.3...14.0.0-rc.0

PR Close #45997
2022-05-23 13:20:10 -07:00
Bob Watson
274c6fa643 docs: remove Narco from hero list in code, text, and images (#46008)
Fixes issue #45769

Removes the malevolent comic book character, "Narco," from the list of heroes. This change removes the reference from the code, text and screenshots used in the documentation and makes other minor edits as necessary.

PR Close #46008
2022-05-17 17:47:03 +00:00
Virginia Dooley
a9b537ca46 docs: update links and TOC (#45897)
Update links and TOC for updated content.

PR Close #45897
2022-05-16 16:07:34 -07:00
Virginia Dooley
711b979be2 docs: Attribute binding changed to include attribute binding only (#45897)
Attribute document broken down into two separate documents:
1) Attribute binding
2) Class and style binding
Content edited with the assistance of the SME.

PR Close #45897
2022-05-16 16:07:33 -07:00
dario-piotrowicz
b6156f41a6 docs(docs-infra): clarify toh-2 error message (#45878)
the second step of the tour of heroes refers to a runtime error which
generally isn't presented to new users since it gets caught by the
TypeScript compiler's strict mode, clarify such detail so not to confuse
readers

resolves #45759

PR Close #45878
2022-05-09 11:23:25 -07:00
George Kalpakas
2ed75324f3 docs: fix ellipsis in code-snippet in creating-libraries guide (#45820)
When hard-coding content in a `<code-example>` tag inside an `.md` file,
the content is treated as HTML by the Markdown processor and thus any
characters with special meaning in HTML have to be encoded (or replaced
with HTML entities).

However, the content that is embedded into `<code-example>` tags via
docregions is treated as text (since it is not parsed by the Markdown
processor) and thus should not have encoded characters or HTML entities.

PR Close #45820
2022-05-09 11:08:46 -07:00
dario-piotrowicz
3f3812e20a docs(docs-infra): improve clarity of toh-pt2 li>button code (#45858)
in the tour of heros part 2 guide the addition of a button with spans is
slighly unclear, so update the code to make things more clear

resolves #45760

PR Close #45858
2022-05-05 16:58:44 -07:00
Andrew Scott
e4538e03d6 refactor(docs-infra): Redirect old document title guide to new router feature (#45857)
The "set-document-title" guide was in place to direct developers to the
`Title` service for managing page titles. Managing the title is now
available in the `Router` package and is much easier. This change
deletes the old guide and redirects it to the section in the router
guide about setting the page title.

PR Close #45857
2022-05-04 16:30:52 -07:00
Paul Gschwendtner
68a6a075f4 build: clean up references to old master branch (#45856)
Cleans up all references to the `master` branch we renamed to
`main` across Angular.

PR Close #45856
2022-05-04 16:23:33 -07:00
dario-piotrowicz
9a04ded85b docs(docs-infra): improve clarity of toh-pt2 click code snippet (#45829)
make clearer that the click code snippet present in the tour of heroes
part 2 guide is not complete but adding ellipsis at the end of the
snippet and also by slightly tweaking the text introducing the snippet

resolves #45758

PR Close #45829
2022-05-02 11:42:12 -07:00
George Kalpakas
71f64f2875 docs(upgrade): move import back into docregion in rollup-config.js (#45778)
This was accidentally broken in #45405.

PR Close #45778
2022-04-27 09:04:09 -07:00
Paul Gschwendtner
067e4c26be build: update systemjs aio boilerplate to work with APF v13+ exports field (#45405)
The SystemJS examples were using an outdated version of rollup that did
not support export fields. Now with the recent changes where we removed
secondary package.json files, the rather old/somewhat outdated SystemJS
examples failed bundling since exports were not considered.

PR Close #45405
2022-04-21 11:09:39 -07:00
Andrew Kushnir
9292953c56 fix(docs-infra): include tslib into SystemJS config in upgrade-module example app (#45706)
This commit updates the SystemJS for one of the example apps (the `upgrade-module` one) to include a resolution rule for the `tslib`. This is needed in case `tslib` is referenced from the framework code (for example in case of downleveling of some operators). This makes it consistent with other example app configs.

PR Close #45706
2022-04-21 11:05:37 -07:00
dario-piotrowicz
dea8c86cd5 feat(router): add ariaCurrentWhenActive input to RouterLinkActive directive (#45167)
add the ariaCurrentWhenActive input to the RouterLinkActive directive so that
users can easily set the aria-current property to their active router
links

resolves #35051

PR Close #45167
2022-04-20 15:14:01 -07:00
Dylan Hunn
89d299105a feat(forms): Implement strict types for the Angular Forms package. (#43834)
This PR strongly types the forms package by adding generics to AbstractControl classes as well as FormBuilder. This makes forms type-safe and null-safe, for both controls and values.

The design uses a "control-types" approach. In other words, the type parameter on FormGroup is an object containing controls, and the type parameter on FormArray is an array of controls.

Special thanks to Alex Rickabaugh and Andrew Kushnir for co-design & implementation, to Sonu Kapoor and Netanel Basal for illustrative prior art, and to Cédric Exbrayat for extensive testing and validation.

BREAKING CHANGE: Forms classes accept a generic.

Forms model classes now accept a generic type parameter. Untyped versions of these classes are available to opt-out of the new, stricter behavior.

PR Close #43834
2022-04-12 17:37:04 +00:00
Joe Martin (Crowdstaffing)
42289f25c6 docs: improve markdown (#45325)
The purpose of the changes is to clean all markdown to match a single pedantic style.

*   To ensure all changes in style are properly separated.
*   To ensure all styled content aligns to nearest 4-character-tab.
*   To ensure all code blocks use the Angular `<code-example>` or `<code-tab>` elements.
*   To ensure all markdown exists outside of html tags.
*   To ensure all images use the Angular style for `<img>` elements.
*   To ensure that all smart punctuation is replaced or removed.

    ```text
    ’, ’, “, ”, –, —, …
    ```

*   To ensure all content does not conflict with the following reserved characters.

    ```text
    @, $, *, &, #, |, <, >,
    ```

*   To ensure all content displays using html entities.

The following changes were made to files in the following directory.

```text
aio/content
```

The target files were markdown files.
The list of excluded files:

```text
.browserslistrc, .css, .conf, .editorconfig, .gitignore, .html, .js, .json, .sh, .svg, .ts, .txt, .xlf,
```

PR Close #45325
2022-04-08 19:36:30 +00:00
Tobias Speicher
4ddcf81e61 refactor: replace deprecated String.prototype.substr() (#45397)
.substr() is deprecated so we replace it with functions which work similarily but aren't deprecated

Signed-off-by: Tobias Speicher <rootcommander@gmail.com>

PR Close #45397
2022-03-24 11:48:09 -07:00
Alan Agius
fc97499676 build(docs-infra): remove defaultProject workspace option (#45410)
The `defaultProject` workspace option has been deprecated. The project to use will be determined from the current working directory.

See: https://github.com/angular/angular-cli/pull/22852

PR Close #45410
2022-03-24 10:49:57 -07:00
Lee Cooper
8a7e624cda fix(docs-infra): fix tour of heroes global styles (#45329)
fix button styles in src/styles.css that are missing from code snippets

PR Close #45329
2022-03-15 13:24:52 -07:00
JiaLiPassion
c7cab69af1 docs(core): update triggerEventHandler samples (#45279)
PR Close #45279
2022-03-09 13:51:54 -08:00
Dmitrij Kuba
c9679760b2 refactor(router): take only the first emitted value of every resolver to make it consistent with guards (#44573)
The router used to wait for the resolvers to complete and take the last
value. The changes here take only the first
emitted value of every resolver and proceed the navigation. This matches
how other guards work in the `Router` code.

Resolves https://github.com/angular/angular/issues/44643

BREAKING CHANGE: Previously, resolvers were waiting to be completed
before proceeding with the navigation and the Router would take the last
value emitted from the resolver.
The router now takes only the first emitted value by the resolvers
and then proceeds with navigation. This is now consistent with `Observables`
returned by other guards: only the first value is used.

PR Close #44573
2022-03-01 17:12:37 +00:00
dario-piotrowicz
9366a3c5f3 docs: improve structure of http example (#44986)
improve the http aio example by:
 - adding a background color to the messages section so that it
   can be distinguished from the others
 - avoid using `hr` elements to divide the various sections, use
   css instead (so that the divisions can also be omitted when
   the sections are not being shown)
 - fix the erroneous presence of an input text element inside a button
   (see: https://github.com/angular/angular/pull/44557#discussion_r787239658)

PR Close #44986
2022-02-28 19:31:25 +00:00
Guillaume Bonnet
cbbf13f100 docs(docs-infra): fix the stackblitz on page i18n-example (#45097)
The previous configuration didn't allow to serve in any language.

Fixes #45066

PR Close #45097
2022-02-28 17:25:40 +00:00
Jessica Janiuk
451bc27b96 test(animations): Fix flaky animations e2e test (#45196)
This adds a 300ms wait to the animations tests to ensure they are fully done animating before asserting.

PR Close #45196
2022-02-24 13:15:31 -08:00
dario-piotrowicz
66f3551a64 test(animations): add route animation delay to pages tests (#45144)
PR #44550 introduced an animation for pages/tabs transitions in the
animations example application, after such change intermittent e2e
failures started to occur (see for example: #45083), add a delay to
account for such animation to all the animations pages/tabs e2e tests so
to fix the flakyness caused by the animation

PR Close #45144
2022-02-24 18:41:55 +00:00