Router Navigate does not call ngOnInit when same page

前端 未结 12 1053
时光取名叫无心
时光取名叫无心 2020-11-28 03:20

I am calling router.navigate on same page with some query string parameters. In this case, ngOnInit() does not call. Is it by default or do I need

12条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-28 03:39

    Angular 9

    I have used the following and it worked.

    onButtonClick() {
        this.router.routeReuseStrategy.shouldReuseRoute = function () {
            return false;
        }
        this.router.onSameUrlNavigation = 'reload';
        this.router.navigate('/myroute', { queryParams: { index: 1 } });
    }
    

提交回复
热议问题