@RouteConfig([
{path: '/about', name: 'About', component: About, useAsDefault: true},
{path: '/test', name: 'Test', component: Test}
])
export class MyApp {
router: Router;
location: Location;
isCollapsed: boolean = true;
// ON ROUTE CHANGE {
this.isCollapsed = true;
// }
constructor(router: Router, location: Location) {
this.router = router;
this.location = location;
}
}
Tôi cần thay đổi giá trị biến trên mọi thay đổi tuyến đường, cách xem sự kiện này trong Angular 2.x?Angular2 xem để thay đổi tuyến đường
Đối với bộ định tuyến mới (=> RC.3), hãy xem http://stackoverflow.com/questions/37137455/angular-2-typescript-error-when-using-subscribe-function-on-new-router-rc -1/37137497 # 37137497 –