首先,我不確定這是否是正確的方式,以實現我想要的。 我想添加一個如下的導出綁定到router.navigate( ) - 方法:添加參數到角路由器。導航
<call [caller]="caller"></call>
的問題是,我從來沒有使用的指令,而是通過路由器ADRESS它:
acceptCall() {
this.router.navigate(["call"]);
}
我怎樣才能達到同樣的出口從第一個例子結合acceptCall() - 方法? 我已經添加了一個輸入()變量,像這樣queryParams試了一下:
@Input() caller: Caller;
acceptCall(caller) {
this.router.navigate(["call"], {queryParams: caller});
}
但是,這是行不通的。
差不多!嘗試'this.router.navigate([「call」,caller]);' – trichetriche
不適合我,我必須修改我的RouterModule.forRoot嗎?我的目前看起來像︰{path:'call',component:CallComponent} – reveN
嗯,是'{path:'call /:caller'}',你可以用this.route.params.subscribe((params:在你的子組件(路由是一個ActivatedRoute) – trichetriche