Angular 7 routerLink directive warning 'Navigation triggered outside Angular zone'

前端 未结 4 1192
既然无缘
既然无缘 2021-02-07 00:57

I am struggling with Angular framework to get my application run smoothly, but I can\'t resolve an issue with routing. I have a top level AppComponent and ap

4条回答
  •  眼角桃花
    2021-02-07 01:44

    It seens a bug, try this as an workaround

    constructor(private ngZone: NgZone, private router: Router) {}
    
    public navigate(commands: any[]): void {
        this.ngZone.run(() => this.router.navigate(commands)).then();
    }
    

提交回复
热议问题