1
如何將某些參數傳遞給我的rotes,就像在舊路由器中一樣?Angular 2路由器傳遞參數並在變化時獲取它們
老
@RouteConfig([
new Route({path: '/home', component: HomeCmp, name: 'HomeCmp' })
])
新
@Routes([
{path: '/login', component: Component}
])
,然後讓他們在認購的變化?
export class AppComponent {
public constructor(private router: Router) {
this.router.changes.subscribe((x) => {
console.log(x);
});
我的意思是在老角有一個狀態,我們可以將事件附加onBefore
ECT並獲得當前的狀態。這實際上是如何工作的。 this.router.changes.subscribe
- 它觸發了更改,但不提供任何有關它的信息 - x
未定義。