我设置的路线如下
const appRoutes: Routes = [ { path: 'login',component: LoginComponent,data: { title: 'Login TTX' } },{ path: 'list',component: ListingComponent,data: { title: ' TTX Home Page',module:'list' } },{ path: '',redirectTo: '/login',pathMatch: 'full' },];
现在当我来’/ list’路线然后在’listing.component.ts’我写下面的代码
export class ListingComponent { public constructor(private router:Router) { //here how i can get **data** of **list** routes } }
public constructor(private route:ActivatedRoute,private router:Router) { console.log(route.snapshot.data['title']); }