在angular2 rc1中,我订阅了路线的变化:
this.router.changes.subscribe(
() => {
console.log(this.location.path());
});
Run Code Online (Sandbox Code Playgroud)
我如何订购angular2 rc3中的路线?router.changes已经不存在了.
constructor(router:Router) {
router.events.subscribe(event:Event => {
if(event instanceof NavigationStart) {
}
// NavigationEnd
// NavigationCancel
// NavigationError
// RoutesRecognized
}
}
Run Code Online (Sandbox Code Playgroud)
要么
constructor(router:Router) {
router.events.forEach(event:Event => {
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2555 次 |
| 最近记录: |