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

前端 未结 4 1131
既然无缘
既然无缘 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:22

    For me, this error was because of a part of the code running outside the NgZone. After which we had a this.ref.detectChanges() running to detect changes. The changes detected would change the DOM and put . This use to break the routing. Solution : We ran the part of code outside NgZone inside NgZone but using this.ngZone.run . This way we did not have to use ref.detectChanged() as the changed(RxJS Subject subscribe) were in NgZone. This solved the routing issue.

    Hope this helps anyone having the same issue.

提交回复
热议问题