如何防止组件在angular2中的查询参数更改时再次加载?

时间:2016-04-21 08:58:47

标签: angular angular2-routing

this.router.navigate(['CurrentComponent', {id: this._id, param1: value}]);

上面的代码更新了当前网址的查询参数。更改URL后,组件再次加载。 如何防止重新加载组件并只更新查询参数?

1 个答案:

答案 0 :(得分:1)

向您的组件添加方法routerCanReuse并返回true

routerCanReuse(next: ComponentInstruction, prev: ComponentInstruction) { return true; }

另见CanReuse