有这个子组件路线:
export const ConsoRoutes: Route[] = [
{
path: 'conso',
component: ConsoComponent
},
{
path: 'conso/:grain',
component: ConsoComponent
}
];
和
export class ConsoComponent implements OnInit {
....
ngOnInit() {
this.sub = this.route.params.subscribe(params => {
var grain = params['grain'];
....
reload some charts.
}
}
查看当前网址http://localhost:5555/dashboard/USERNAME/conso
使用另一个用户名:
this.$router.navigateByUrl(this.$router.url.replace(this.username, newUsername));
没有触发this.route.params.subscribe
,如何强制订阅活动?
我也尝试ApplicationRef .tick()
,也不会调用订阅。
答案 0 :(得分:0)
this.sub = this.route.url.subscribe(
....
);