Navigation triggered outside Angular zone, did you forget to call 'ngZone.run()'?

后端 未结 4 1174
迷失自我
迷失自我 2020-12-25 10:42

I am using Angular 7 and facing an issue => after login the API GET calls successfully and the component receiving data too, but UI is not displaying that data.

Whe

4条回答
  •  一个人的身影
    2020-12-25 11:07

    My issue fixed by wrapping the router navigation command in ngZone. Please check the code below

    in constructor add "private zone: NgZone".

    private zone: NgZone
    
    this.zone.run(() => {
                        this.router.navigate(['/login']);
                    });
    

提交回复
热议问题