angular-cn/aio/dist/generated/docs/api/router/CanActivateChild.json

5 lines
50 KiB
JSON
Raw Permalink Normal View History

{
"id": "api/router/CanActivateChild",
"title": "CanActivateChild",
"contents": "\n\n<article>\n <div class=\"breadcrumb-container\">\n <div class=\"breadcrumb\">\n <script type=\"application/ld+json\">\n {\n \"@context\": \"http://schema.org\",\n \"@type\": \"BreadcrumbList\",\n \"itemListElement\": [\n { \"@type\": \"ListItem\", \"position\": 1, \"item\": { \"@id\": \"https://angular.io//api\", \"name\": \"API\" } },\n { \"@type\": \"ListItem\", \"position\": 2, \"item\": { \"@id\": \"https://angular.io/api/router\", \"name\": \"@angular/router\" } },\n { \"@type\": \"ListItem\", \"position\": 3, \"item\": { \"@id\": \"https://angular.io/api/router/CanActivateChild\", \"name\": \"CanActivateChild\" } }\n ]\n }\n </script>\n <a href=\"/api\">API</a> > <a href=\"api/router\">@angular/router</a>\n </div>\n <div class=\"github-links\">\n <a href=\"https://github.com/angular/angular/edit/master/packages/router/src/interfaces.ts?message=docs(router)%3A%20describe%20your%20change...#L99-L189\" aria-label=\"Suggest Edits\" title=\"Suggest Edits\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">mode_edit</i></a>\n <a href=\"https://github.com/angular/angular/tree/12.0.0-next.7/packages/router/src/interfaces.ts#L99-L189\" aria-label=\"View Source\" title=\"View Source\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">code</i></a>\n</div>\n </div>\n \n <header class=\"api-header\">\n <h1 id=\"canactivatechild\">CanActivateChild<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/router/CanActivateChild#canactivatechild\"><i class=\"material-icons\">link</i></a></h1>\n \n <label class=\"api-type-label interface\">interface</label>\n \n \n \n </header>\n \n <aio-toc class=\"embedded\"></aio-toc>\n\n <div class=\"api-body\">\n \n <section class=\"short-description\">\n <p>Interface that a class can implement to be a guard deciding if a child route can be activated.\nIf all guards return <code>true</code>, navigation continues. If any guard returns <code>false</code>,\nnavigation is cancelled. If any guard returns a <code><a href=\"api/router/UrlTree\" class=\"code-anchor\">UrlTree</a></code>, current navigation\nis cancelled and a new navigation begins to the <code><a href=\"api/router/UrlTree\" class=\"code-anchor\">UrlTree</a></code> returned from the guard.</p>\n\n <p><a href=\"api/router/CanActivateChild#description\">See more...</a></p>\n </section>\n \n \n <section class=\"interface-overview\">\n<code-example language=\"ts\" hidecopy=\"true\">\ninterface <a href=\"api/router/CanActivateChild\" class=\"code-anchor\">CanActivateChild</a> {\n <a class=\"code-anchor\" href=\"api/router/CanActivateChild#canActivateChild\"><span class=\"member-name\">canActivateChild</span>(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable&#x3C;boolean | UrlTree> | Promise&#x3C;boolean | UrlTree> | boolean | UrlTree</a>\n}\n</code-example>\n\n \n \n\n\n \n \n\n</section>\n\n \n\n \n \n<section class=\"description\">\n <h2 id=\"description\">Description<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/router/CanActivateChild#description\"><i class=\"material-icons\">link</i></a></h2>\n <p>The following example implements a <code><a href=\"api/router/CanActivateChild\" class=\"code-anchor\">CanActivateChild</a></code> function that checks whether the\ncurrent user has permission to activate the requested child route.</p>\n<code-example>\nclass UserToken {}\nclass Permissions {\n canActivate(user: UserToken, id: string): boolean {\n return true;\n }\n}\n\n@<a href=\"api/core/Injectable\" class=\"code-anchor\">Injectable</a>()\nclass CanActivateTeam implements <a href=\"api/router/CanActivateChild\" class=\"code-anchor\">CanActivateChild</a> {\n constructor(private permissions: Permissions, private currentUser: UserToken) {}\n\n canActivateChild(\n route: <a href=\"api/router/ActivatedRouteSnapshot\" class=\"code-anchor\">Ac
}