import { ActivatedRoute, Params, Router } from '@angular/router';
constructor(private activatedRoute: ActivatedRoute){
}
this.activatedRoute.params.subscribe( (params)=>{
//子router抓不到
})
{ path: 'a', component:aComponent, children: [
{ path: 'b', component: bComponent},
{ path: 'f', component: bComponent},
{ path: 'g', component: bComponent}]},
{ path: 'c', component:cComponent},
{ path: 'd', component:dComponent},
{ path: 'e', component:eComponent},
假定連線到 /a/b
,/b是/a的子網路,如果是/c,/d,/e,activatedRoute都抓得到,但/a/b抓不到,目前想抓出是在哪個子網路b,f,g
本來想用ngAfterViewChecked() {}
完再去抓網址,但感覺方法不太恰當
試試這樣
import { Router } from '@angular/router';
constructor(private _router: Router){
this._router.event.subscribe(console.log)
}