更新时间:2023-02-13 23:30:18
当导航仅更改路由参数时,目前无法让 Angular2 路由器重新创建组件.有计划支持这一点.
Currently there is no way to make the Angular2 router recreate the component when the navigation only changes a route parameter. There are plans to support that.
您可以通过订阅路由参数更改并在那里执行代码来解决
You can work around by subscribing to route parameter changes and execute the code there
constructor(private route:ActivatedRoute) {}
ngOnInit() {
route.params.subscribe(p => {
this.myInit(); // successive params changes
});
this.myInit(); // first time
}
myInit() {
jQuery($('.selectpicker').selectpicker()';
}