angular-docs-cn/aio/content/guide
Andrew Scott 8a56c99f87 docs(router): Update router guide to use UrlTree for guard redirects (#37100)
The current implementation for redirecting users inside guards was in place
before the feature was added to allow `CanActivate` and `CanActivateChild` guards
to return `UrlTree` for redirecting users.

Returning `UrlTree` should be the default method, as it provides a more desirable
redirecting experience. When using `router.navigate` followed by `return false`,
the `Router` calls `resetUrlToCurrentUrlTree` (in the `finalize` operator) before
processing the navigation to the new route.  This can result in an undesirable
history if the navigation was the first navigation in the application - that is,
the route will briefly be reset to just `/` (see #36187).

Fixes #36187

PR Close #37100
2020-05-14 12:23:35 -07:00
..
accessibility.md docs: replaces on with of (#36773) 2020-05-13 15:52:08 -07:00
ajs-quick-reference.md docs: refactor routing doc (#35566) 2020-04-16 10:36:01 -07:00
angular-compiler-options.md docs: changes AoT to AOT for consistency (#35112) 2020-02-04 10:43:33 -08:00
animations.md feat(docs-infra): simplify image styles and remove figure references (#33748) 2019-11-14 09:27:02 -08:00
aot-compiler.md docs: correct typos in doc for template type guards (#37090) 2020-05-13 16:01:20 -07:00
aot-metadata-errors.md docs: changes AoT to AOT for consistency (#35112) 2020-02-04 10:43:33 -08:00
app-shell.md docs: update universal docs for new ivy implementation (#33040) 2019-10-21 11:25:44 -04:00
architecture-components.md docs: improve startup nav, naming, and terminology (#35533) 2020-04-22 17:08:29 -04:00
architecture-modules.md feat(docs-infra): simplify image styles and remove figure references (#33748) 2019-11-14 09:27:02 -08:00
architecture-next-steps.md docs: Remove duplicate `and` (#37067) 2020-05-13 15:59:41 -07:00
architecture-services.md feat(docs-infra): simplify image styles and remove figure references (#33748) 2019-11-14 09:27:02 -08:00
architecture.md docs: place download section in architecture to the top (#36565) 2020-04-21 12:50:29 -04:00
attribute-directives.md docs: change p to pointer for better understanding (#34927) 2020-01-28 13:04:25 -08:00
bazel.md build: depend on bazelisk rather than directly on Bazel (#36078) 2020-03-16 10:58:06 -07:00
bootstrapping.md docs: change page title and minor edit (#36021) 2020-04-01 13:16:18 -07:00
browser-support.md docs: add FireFox ESR to the supported list (#36973) 2020-05-08 14:41:26 -07:00
build.md docs: fix typo (#36665) 2020-04-20 13:36:40 -04:00
cheatsheet.md docs: clarify meaning of injectable decorator (#31573) 2019-07-16 23:57:50 -04:00
cli-builder.md docs: add link to publish a library in ivy guide (#34986) 2020-01-27 10:50:52 -08:00
comparing-observables.md fix(docs-infra): convert hard-coded `comparing-observables` examples into a proper mini-app (#34327) 2020-01-21 13:14:46 -05:00
complex-animation-sequences.md docs: remove redundant whitespaces and fix minor typos (#33422) 2019-10-29 11:39:17 -07:00
component-interaction.md docs: apply standard header case convention (#34196) 2020-01-10 08:38:53 -08:00
component-styles.md docs: apply standard header case convention (#34196) 2020-01-10 08:38:53 -08:00
creating-libraries.md docs: move asset management section (#35665) 2020-03-18 15:55:44 -07:00
dependency-injection-in-action.md docs(core): fix typo in dependency injection guide (interactive --> interacting) (#34853) 2020-01-21 13:03:04 -05:00
dependency-injection-navtree.md docs: fix typo in Dependency Injection guide (#36304) 2020-03-30 11:14:55 -07:00
dependency-injection-providers.md docs(core): add missing quote in dependency injection provider guide (#34854) 2020-01-21 13:02:29 -05:00
dependency-injection.md docs: apply standard header case convention (#34196) 2020-01-10 08:38:53 -08:00
deployment.md fix(core): correct "development mode" console message (#36571) 2020-05-12 10:50:12 -07:00
deprecations.md docs: remove the note about @angular/http from the deprecations guide (#37070) 2020-05-14 11:01:18 -07:00
displaying-data.md docs: Change important alert of ngFor (#36176) 2020-03-23 11:36:09 -07:00
docs-style-guide.md docs: improve startup nav, naming, and terminology (#35533) 2020-04-22 17:08:29 -04:00
dynamic-component-loader.md docs: apply standard header case convention (#34196) 2020-01-10 08:38:53 -08:00
dynamic-form.md docs: refactor dynamic forms topic as tutorial (#36465) 2020-05-12 10:49:23 -07:00
elements.md docs: place download section to the top of the page (#36067) 2020-04-03 11:00:26 -07:00
entry-components.md docs: apply standard header case convention (#34196) 2020-01-10 08:38:53 -08:00
feature-modules.md docs: apply standard header case convention (#34196) 2020-01-10 08:38:53 -08:00
file-structure.md docs: replace `browserslist` with `.browserslistrc` (#36504) 2020-04-08 12:12:03 -07:00
form-validation.md docs: refactor form validation doc to be task-oriented (#36374) 2020-05-11 10:59:50 -07:00
forms-overview.md feat(docs-infra): simplify image styles and remove figure references (#33748) 2019-11-14 09:27:02 -08:00
forms.md docs: place download section in angular forms to the top (#36075) 2020-04-03 11:05:31 -07:00
frequent-ngmodules.md docs: apply standard header case convention (#34196) 2020-01-10 08:38:53 -08:00
glossary.md docs: refactor lifecycle hooks doc topic for task orientation (#36353) 2020-05-13 15:51:21 -07:00
hierarchical-dependency-injection.md fix(docs-infra): fix parameters with @Optional() decorator do not match declared, optional type (#35150) 2020-02-07 09:58:31 -08:00
http.md docs: add string-union type note (#35859) 2020-04-16 09:47:21 -07:00
i18n.md docs: Ivy i18n guide updates for localize option (#34053) 2019-12-03 10:14:15 -08:00
ivy-compatibility-examples.md docs: add example to illustrate binding order differences in ivy (#36643) 2020-04-17 12:29:58 -04:00
ivy-compatibility.md docs: add example to illustrate binding order differences in ivy (#36643) 2020-04-17 12:29:58 -04:00
ivy.md docs: remove speeding update ngcc section (#36049) 2020-03-13 07:58:14 -07:00
language-service.md feat(docs-infra): simplify image styles and remove figure references (#33748) 2019-11-14 09:27:02 -08:00
lazy-loading-ngmodules.md docs: apply standard header case convention (#34196) 2020-01-10 08:38:53 -08:00
libraries.md docs: apply standard header case convention (#34196) 2020-01-10 08:38:53 -08:00
lifecycle-hooks.md docs: refactor lifecycle hooks doc topic for task orientation (#36353) 2020-05-13 15:51:21 -07:00
migration-dynamic-flag.md docs: fix migrations formatting (#33267) 2019-12-05 13:06:01 -08:00
migration-injectable.md docs: fix migrations formatting (#33267) 2019-12-05 13:06:01 -08:00
migration-localize.md docs: fix migrations formatting (#33267) 2019-12-05 13:06:01 -08:00
migration-module-with-providers.md docs: apply standard header case convention (#34196) 2020-01-10 08:38:53 -08:00
migration-renderer.md docs: fix migrations formatting (#33267) 2019-12-05 13:06:01 -08:00
migration-undecorated-classes.md docs: apply standard header case convention (#34196) 2020-01-10 08:38:53 -08:00
module-types.md docs: apply standard header case convention (#34196) 2020-01-10 08:38:53 -08:00
ngmodule-api.md docs: remove prerequisite section in NgModules docs (#31169) 2019-07-17 13:26:00 -04:00
ngmodule-faq.md docs: apply standard header case convention (#34196) 2020-01-10 08:38:53 -08:00
ngmodule-vs-jsmodule.md docs: apply standard header case convention (#34196) 2020-01-10 08:38:53 -08:00
ngmodules.md refactor(docs-infra): remove `linenums=false` since it is now the default (#31674) 2019-07-24 14:38:54 -07:00
npm-packages.md build(docs-infra): update docs examples `package.json` templates wrt `core-js` (#36143) 2020-04-06 15:31:07 -07:00
observables-in-angular.md docs: fix typo in Observables in Angular guide (#33509) 2019-10-31 22:21:00 +00:00
observables.md docs: clarify observables doc with new titles and tooltips (#36023) 2020-03-27 10:49:03 -07:00
pipes.md docs: place download section in angular pipes to the top (#36073) 2020-04-03 11:01:08 -07:00
practical-observable-usage.md fix(docs-infra): rename "title" by "header" to avoid unwanted tooltips (#26396) 2018-10-17 11:05:29 -07:00
providers.md docs: clarifies the service limitation (#36349) 2020-05-14 11:59:44 -07:00
reactive-forms.md docs: update reactive forms page (#35969) 2020-04-07 15:24:17 -07:00
releases.md docs: remove version ^7.0.0 from LTS support (#36708) 2020-04-20 13:38:04 -04:00
reusable-animations.md docs: remove redundant whitespaces and fix minor typos (#33422) 2019-10-29 11:39:17 -07:00
route-animations.md docs: Clarifies code section is a continuation from the section above (#35111) 2020-02-06 15:31:41 -08:00
router-tutorial.md docs: Add new section, tutorials, to left nav, and a tutorial on routing (#36545) 2020-05-05 11:51:19 -07:00
router.md docs(router): Update router guide to use UrlTree for guard redirects (#37100) 2020-05-14 12:23:35 -07:00
rx-library.md docs: update rxjs refs (#31780) 2019-08-08 12:15:29 -07:00
schematics-authoring.md docs: apply standard header case convention (#34196) 2020-01-10 08:38:53 -08:00
schematics-for-libraries.md docs: fix typo in Schematics guide (#36328) 2020-03-30 15:32:05 -07:00
schematics.md docs: make page titles and toc task-oriented (#36024) 2020-04-01 13:16:48 -07:00
security.md docs: add CSRF to XSRF section of http guide (#32933) 2019-11-21 16:57:12 -05:00
service-worker-communications.md docs: replace into with in (#36778) 2020-05-08 09:39:26 -07:00
service-worker-config.md feat(service-worker): include `CacheQueryOptions` options in ngsw-config (#34663) 2020-05-01 09:44:07 -07:00
service-worker-devops.md docs: clarrify use of sw behind redirect (#32915) 2019-10-21 16:50:52 -04:00
service-worker-getting-started.md feat(docs-infra): simplify image styles and remove figure references (#33748) 2019-11-14 09:27:02 -08:00
service-worker-intro.md docs: reference articles specifically (#32221) 2019-08-26 15:03:04 -07:00
set-document-title.md docs: apply standard header case convention (#34196) 2020-01-10 08:38:53 -08:00
setup-local.md docs: improve startup nav, naming, and terminology (#35533) 2020-04-22 17:08:29 -04:00
sharing-ngmodules.md docs: apply standard header case convention (#34196) 2020-01-10 08:38:53 -08:00
singleton-services.md docs: reword explanation for using singleton services decorative to be more understandable (#35002) 2020-03-02 09:30:54 -08:00
static-query-migration.md build: bump year (#34651) 2020-01-13 07:21:43 -08:00
structural-directives.md docs: correct typos in doc for template type guards (#37090) 2020-05-13 16:01:20 -07:00
styleguide.md docs: apply standard header case convention (#34196) 2020-01-10 08:38:53 -08:00
template-syntax.md docs: minor typos (#36772) 2020-05-13 15:51:47 -07:00
template-typecheck.md docs: add doc for template type guards to stuctural-directives.md (#34549) 2020-05-12 14:40:01 -07:00
testing.md docs: refactor routing doc (#35566) 2020-04-16 10:36:01 -07:00
transition-and-triggers.md docs: fix animations example/remove 1st person (#35046) 2020-02-04 08:58:04 -08:00
typescript-configuration.md docs: add strictTemplates in place of fullTemplateTypeCheck (#35628) 2020-03-30 10:57:15 -07:00
universal.md docs: remove unneeded code from `universal` example/guide (#36483) 2020-04-16 09:43:42 -07:00
updating-to-version-9.md docs: update deprecation guide to move deprecated APIs to removals (#36891) 2020-05-05 11:55:58 -07:00
updating.md docs: remove the release schedule from docs (#34474) 2020-02-06 14:29:21 -08:00
upgrade-performance.md docs: apply standard header case convention (#34196) 2020-01-10 08:38:53 -08:00
upgrade-setup.md docs: apply standard header case convention (#34196) 2020-01-10 08:38:53 -08:00
upgrade.md docs(upgrade): remove outdated/non-applicable AOT section from upgrade guide (#36015) 2020-03-18 10:00:02 -07:00
user-input.md feat: add a temp solution to support passive event listeners. (#34503) 2020-02-24 17:30:04 -08:00
using-libraries.md docs: apply standard header case convention (#34196) 2020-01-10 08:38:53 -08:00
visual-studio-2015.md docs: remove redundant whitespaces and fix minor typos (#33422) 2019-10-29 11:39:17 -07:00
web-worker.md docs: add missing command in `WebWorker` guide (#36397) 2020-04-06 09:29:17 -07:00
workspace-config.md docs: apply standard header case convention (#34196) 2020-01-10 08:38:53 -08:00
zone.md docs(zone.js): fix typos in NgZone guide code example (#36597) 2020-04-13 08:16:59 -07:00