ami*_*tar 3 refresh reload angular
我正在使用 angular 8,并希望在不刷新整个页面的情况下在同一 url 上刷新我的组件。我正在尝试使用 router.navigate 但它对我不起作用。我尝试过
location.reload,window.location.reload但它花费了太多时间并且刷新了整个页面。以下是我的相同代码:
this.snackBar.open('Data Updated Successfully', 'Undo', {
duration: 5000,
});
this.router.navigate(['/get_customer_details/'+this.customer_details_id]);
console.log(this.customer_details_id);
this.ngOnInit();
Run Code Online (Sandbox Code Playgroud)
默认情况下RouteReuseStrategy,Angular 为 true。您需要将其更改为 false。
在构造函数中使用以下代码
constructor(private route: ActivatedRoute, private router: Router) {
this.router.routeReuseStrategy.shouldReuseRoute = () => false;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11070 次 |
| 最近记录: |