Angular 路由在调用自身时不调用订阅
Angular Route dont call subscription when called itself
以下是我的代码,当页面加载和组件第一次加载时订阅调试器第一次点击,当按钮被点击并调用 search
函数时。来自 nginit 的订阅没有成功。
知道为什么
public search(): void {
debugger;
this.router.navigate(['/logs/error'], { queryParams: { file: this.searchQuery }});
}
ngOnInit() {
this.sub = this.route.params.subscribe(params => {
debugger; // (+) converts string 'id' to a number
// In a real app: dispatch action to load the details here.
});
}
如果想在query参数发生变化时进行跟踪,需要使用
this.route.queryParams.subscribe(...)
不是参数
以下是我的代码,当页面加载和组件第一次加载时订阅调试器第一次点击,当按钮被点击并调用 search
函数时。来自 nginit 的订阅没有成功。
知道为什么
public search(): void {
debugger;
this.router.navigate(['/logs/error'], { queryParams: { file: this.searchQuery }});
}
ngOnInit() {
this.sub = this.route.params.subscribe(params => {
debugger; // (+) converts string 'id' to a number
// In a real app: dispatch action to load the details here.
});
}
如果想在query参数发生变化时进行跟踪,需要使用
this.route.queryParams.subscribe(...)
不是参数