1.重定向
关键词 redirectTo,pathMath; redirectTo 表示 地址,pathMath 表示 匹配原则 (full:完全一致,prefix:前缀一致)。 用法:{path:'',redirectTo:'/page1',pathMatch:'full'};
2.子路由
关键词 children 使用方法: {path:'page1',children:[{path:'page3',component:Page3Component}]}
3辅助路由
关键词 outlet 用法 <a [routerLink]="['',{outlets:{test1:'page1',test2:'page2'}}]"> <router-outlet name='test1'></router-outlet> <router-outlet name='test2'></router-outlet> {path:'page1',component:Page1Component,outlet:'test1'},{path:'page2',outlet:'test2'}; 从代码字面上来看,就是一下传进多个路由的信息,辅助理由的组件只能在自己outlet的属性的插座里显示,辅助路由也只能显示设置outlet属性为自身的组件。
4.路由守卫
关键词 canActivate; 用法: 1.新建一个守卫 import{ CanActivate } from '@angular/router'; export Guard class implements CanActivate { canActivate(){ return boolean; } } 2.依赖注入到配置路由的ts中 import { Guard } from ....; @ngModules{ .....,providers:[Guard] }; 3.调用 {path:'page1',canAcvitate:[Guard]} 守卫可以配置多个,所以是一个数组。