gpt4 book ai didi

angular - 如何在 Angular 7,8 中重新加载整个页面而不刷新?

转载 作者:行者123 更新时间:2023-12-04 02:45:45 24 4
gpt4 key购买 nike

I am working with angular 8 and want to refresh my component on same url without refresh whole page. I am trying with router.navigate but its not working for me. I tried with location.reload and window.location.reload but it takes too much time and it refresh whole page. Below is my code for same :


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();

最佳答案

默认 RouteReuseStrategy Angular 是真的。您需要将其更改为 false。

在构造函数中使用以下代码

constructor(private route: ActivatedRoute, private router: Router) {
this.router.routeReuseStrategy.shouldReuseRoute = () => false;
}

关于angular - 如何在 Angular 7,8 中重新加载整个页面而不刷新?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57325155/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com