Commit graph

1887 commits

Author SHA1 Message Date
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
Tom Eustace
adb21a2416 docs: add angular#bundler to Enforcing Trusted Types section (#45450)
When a Content Security Policy is defined that uses trusted-types in an application that uses lazy chunk files, ng
serve will be broken as angular#bundler entry needs to be added to
Content Security Policy.

Fixes #44647

PR Close #45450
2022-06-10 16:11:41 +00:00
alefra
55a0efede2 docs: modify header and path (#45828)
Change header and path to match with file in the example folder

PR Close #45828
2022-06-10 16:11:09 +00:00
alefra
d6c370bc67 docs: modify header and path of code-example (#45828)
In the example, @ContentChild is used in app.component.ts but the component we want to project content into is example-zippy.component.ts.
PR Close #45828
2022-06-10 16:11:09 +00:00
dario-piotrowicz
51297e1493 docs: fix "for to learn more" typo (#46095)
PR Close #46095
2022-06-10 14:24:37 +00:00
dario-piotrowicz
521c7dd03e docs: add standalone info to aio glossary (#46095)
add information about standalone components, directives and pipes in the
guide glossary

PR Close #46095
2022-06-10 14:24:37 +00:00
Younes Jaaidi
3b304219c4 docs: use better wording (#46314)
Co-authored-by: Andrew Kushnir <43554145+AndrewKushnir@users.noreply.github.com>
PR Close #46314
2022-06-10 14:21:06 +00:00
Younes Jaaidi
78ae490e0a docs: clarify OnPush (#46314)
PR Close #46314
2022-06-10 14:21:06 +00:00
Alan Agius
7391143dd3 docs: remove azure builder reference (#46285)
This builder is not compatible with newer versions of the Angular CLI.

See https://github.com/angular/angular-cli/issues/23255 for more context

PR Close #46285
2022-06-08 12:40:23 -07:00
Alan Agius
a9e8a212f8 docs: mark version 13 as LTS in releases guide (#46268)
Verson 13 is now in LTS.

PR Close #46268
2022-06-06 11:48:05 -07:00
mgechev
d67cf922c2 docs: add i18n video to the overview page (#46273)
PR Close #46273
2022-06-06 11:46:49 -07:00
Phalgun Vaddepalli
385b5ec92c docs: removed outdated migration documentation (#46257)
Fixes #46236

PR Close #46257
2022-06-06 11:42:51 -07:00
dario-piotrowicz
3ab9d48ef0 docs: change wrong alters to callouts (#46262)
change the alerts present in the docs to callouts so
that their header can be properly rendered
(since alters don't support have headers)

PR Close #46262
2022-06-06 10:17:53 -07:00
Fabrizio Fallico
6724e43bf6 docs: fix missing closing div in http page (#46258)
PR Close #46258
2022-06-06 10:15:37 -07:00
dario-piotrowicz
ee98f4eaf8 docs: update outdated link title for structural directives guide (#46228)
amend the aio glossary using as the structural-directives guide link's title the
outdated heading of that guide (changed in PR #44895)

PR Close #46228
2022-06-03 10:08:15 -07:00
dario-piotrowicz
6eb234b622 docs: replace wrong NgFor with NgForOf (#46228)
amend the aio structural-directives guide incorrectly mentioning
`NgFor` instead of `NgForOf` as a structural directive

PR Close #46228
2022-06-03 10:08:15 -07:00
Alex Rickabaugh
69d374635f docs: replace Angular Labs with Developer Preview docs (#46050)
This commit updates the releasing/versioning doc on angular.io to cover the
new "Developer Preview" concept. This replaces the old section on the no-
longer-relevant "Angular Labs".

PR Close #46050
2022-06-01 16:01:59 -07:00
George Looshch
f22f451310 docs: replace double dashes with m-dashes, fix typos (#46174)
Fixes #46173

PR Close #46174
2022-06-01 11:02:41 -07:00
Alex Rickabaugh
6a8290c1f0 docs: update release and update guides for v14 (#46200)
This commit adds content related to Angular v14 to the `releases.md` and
`update-to-latest-version.md` guides on AIO.

PR Close #46200
2022-05-31 15:17:21 -07:00
Billy Lando
253ac15ae8 docs: replace broken <br/> from service worker (#46193)
PR Close #46193
2022-05-31 12:02:35 -07:00
Rune Andersen Hartvig
3af2cd5306 docs: fix template example (#46170)
Fix a typo that prevents an example to show.
PR Close #46170
2022-05-31 11:59:47 -07:00
Matt Shaffer
efed24eb70 docs: rename stage to staging (#46164)
PR Close #46164
2022-05-31 11:59:18 -07:00
Matt Shaffer
d721934dfa docs: update example file name (#46164)
PR Close #46164
2022-05-31 11:59:18 -07:00
dario-piotrowicz
2863dff7fa docs: change wrong alert to callout (#46145)
change the alert present in the lifecycicle-hook docs to a callout so
that its header can be properly rendered (since alters don't support have headers)

PR Close #46145
2022-05-27 09:30:22 -07:00
Ian Gregory
6a4353cb40 docs: close lightbox div to fix page display (#46155)
PR Close #46155
2022-05-26 17:42:52 -07:00
mgechev
bb16b1919a docs: fix incorrect title in the roadmap (#46140)
Ensure we're using h3 titles for consistency.

PR Close #46140
2022-05-26 17:42:24 -07:00
dario-piotrowicz
7c6b740b97 docs: fix &hellip; presented in aio code docs (#46123)
the symbol `&hellip;` displays correctly in code-example blocks and in
plain html text, it does however not work correctly for code espressed
using backticks, fix such occurrences by replacing `&hellip;` with `...`

PR Close #46123
2022-05-25 11:30:30 -07:00
mgechev
8db9930aa0 docs: update the Angular roadmap as of May 2022 (#46117)
* Update project completion status
* Update project description based on state
* Add new projects to the future section

PR Close #46117
2022-05-25 11:23:53 -07:00
dario-piotrowicz
9ed50ad36f docs: replace wrong hyphen with # in aio cheatsheet (#46125)
replace the hyphen symbol wrongly used in the aio cheatsheet
doc to create a template variable with the proper # symbol

PR Close #46125
2022-05-24 10:49:52 -07:00
Roopesh Chinnakampalli
983aa233cf docs: corrected the misspelled word (#46126)
innovation -> invocation
PR Close #46126
2022-05-24 10:47:46 -07:00
David Schmidt
bd94c076c7 docs: fix FormRecord example (#46124)
PR Close #46124
2022-05-24 10:47:07 -07:00
A. J. Javier
281d4b7ace docs: fix angularfire2 hyperlink (#46046)
PR Close #46046
2022-05-23 13:52:11 -07: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
Nathan Nontell
8461259334 docs(docs-infra): update createComponent description to fix incorrect method name and invalid use of html escaping (#46074)
PR Close #46074
2022-05-23 13:21:45 -07:00
Jerome Kruse
e235c70d7d docs: update service-worker-config to more clearly describe behavior (#45909)
Fixes #45280

PR Close #45909
2022-05-23 13:17:51 -07:00
J Rob Gant
1bd0532e87 docs: Remove outdated note (#46022)
Component.styles can now use SCSS or LESS preprocessors.

PR Close #46022
2022-05-23 09:53:40 -07:00
Pawel Kozlowski
ae18f00023 docs: add guide to standalone components preview (#46058)
Add a new page in developers guide section with the general
overview of the standalone components, directives and pipes
Additional APIs (bootstrapApplication, router, DI) as also
covered.

PR Close #46058
2022-05-23 09:15:06 -07:00
Dylan Hunn
37bf6932e9 fix(forms): Add a nonNullable option to FormControl for consistency.
DEPRECATED:

The `initialValueIsDefault` option has been deprecated and replaced with the otherwise-identical `nonNullable` option, for the sake of naming consistency.
2022-05-19 15:49:02 -07:00
George Kalpakas
737e08094c fix(docs-infra): correctly style the CLI version in code snippet (#46020)
Some CLI versions (such as `@next`) are not parsed (and thus not
formatted) correctly in code snippets. Fix this by explicitly adding an
appropriate CSS class to the `<aio-angular-dist-tag>` elements to let
PrettyPrint know how to style this token.

PR Close #46020
2022-05-17 18:28:30 +00:00
Virginia Dooley
6952a0a3e6 docs: add template overview doc (#45897)
Organize bottom list into cards.

PR Close #45897
2022-05-16 16:07:34 -07: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
6276bed4ab docs: updated Property binding doc (#45897)
Refined and edited as a task-based document with the assistance
of the SME
Add missing prerequisites and what's next sections

PR Close #45897
2022-05-16 16:07:34 -07:00
Virginia Dooley
429ebd2558 docs: updated Event binding doc (#45897)
Document updated with the assistance of the SME.
Add missing prerequisites and what's next sections
Make suggested changes to Event binding doc.

PR Close #45897
2022-05-16 16:07:34 -07:00
Virginia Dooley
4eb529e601 docs: new binding overview doc (#45897)
New binding overview doc. Content derived from existing docs.
Make changes suggested in PR for binding overview doc.
Deleted bottom paragraph from Binding overview per comments made by
atscott and alxhub.

PR Close #45897
2022-05-16 16:07:34 -07:00
Virginia Dooley
571a01e099 docs: Text interpolation doc amended to be task-based (#45897)
Rewrite document as task-based
Add prerequisites and What's next sections.
Content edited with the assistance of the SME.

PR Close #45897
2022-05-16 16:07:34 -07:00
Virginia Dooley
41715431fb docs: new Pipes in templates doc (#45897)
New using a Pipe in a template document.
Content taken from the original Pipes document.
Content edited with the assistance of the SME.

PR Close #45897
2022-05-16 16:07:34 -07:00
Virginia Dooley
3cfc260282 docs: Pipes transform data new doc (#45897)
New Transforming data with pipes document.
Content taken from the original Pipes document.
Content edited with the assistance of the SME.

PR Close #45897
2022-05-16 16:07:33 -07:00
Virginia Dooley
e0a9a41066 docs: Understanding pipes new doc (#45897)
New overview file using the Understanding… format.
The original Pipes document was considered too long and
was broken down into several separate topics.
Content edited with the assistance of the SME.

PR Close #45897
2022-05-16 16:07:33 -07:00
Virginia Dooley
96e23383ad docs: new Template expressions overview doc (#45897)
Create a new Template expressions overview doc in the Understanding...
format.

PR Close #45897
2022-05-16 16:07:33 -07:00
Virginia Dooley
c825560617 docs: class-binding created as a separate task-based doc (#45897)
Class and style binding was pulled out of Attribute, class, and style
binding doc and put in its own doc.
Content edited with the assistance of the SME.
Prerequisites and What's next sections were added.

PR Close #45897
2022-05-16 16:07:33 -07:00