Reputation: 3451
On an admin page, I have a logout button that looks like this:
<button class="btn btn-primary pull-right" (click)="logout()">Logout</button>
In admin.component.ts, the logout button is:
logout() {
this._router.navigate(['/login']);
}
When I click the logout button, I get the following error message in the chrome developer console:
Uncaught (in promise): Error↵Error↵ at Error.ZoneAwareError (http://localhost:4200/polyfills.bundle.js:3051:33)↵ at ZoneAwareError (http://localhost:4200/polyfills.bundle.js:3048:35)↵ at injectionError (http://localhost:4200/vendor.bundle.js:5912:86)↵ at noProviderError (http://localhost:4200/vendor.bundle.js:5950:12)↵ at ReflectiveInjector_._throwOrNull (http://localhost:4200/vendor.bundle.js:7451:19)↵ at ReflectiveInjector_._getByKeyDefault (http://localhost:4200/vendor.bundle.js:7490:25)↵ at ReflectiveInjector_._getByKey (http://localhost:4200/vendor.bundle.js:7422:25)↵ at ReflectiveInjector_.get (http://localhost:4200/vendor.bundle.js:7291:21)↵ at AppModuleInjector.NgModuleInjector.get (http://localhost:4200/vendor.bundle.js:8238:52)↵ at PreActivation.getToken (http://localhost:4200/vendor.bundle.js:40056:25)↵ at MergeMapSubscriber.project (http://localhost:4200/vendor.bundle.js:40010:48)↵ at MergeMapSubscriber._tryNext (http://localhost:4200/vendor.bundle.js:49726:27)↵ at MergeMapSubscriber._next (http://localhost:4200/vendor.bundle.js:49716:18)↵ at MergeMapSubscriber.Subscriber.next (http://localhost:4200/vendor.bundle.js:23374:18)↵ at ArrayObservable._subscribe (http://localhost:4200/vendor.bundle.js:49285:28)"
This was actually working before, but now if I navigate to any route besides the current route I am on, I get this error message. There error message is cryptic to me, so I am not sure what is causing it.
Upvotes: 0
Views: 308
Reputation: 60518
What version of zone.js are you using? (You can look in your package.json file.)
There was a bug in one of the versions of zone.js that caused it to generate this error, masking the real error and making it close to impossible to figure out what is wrong.
At the time, I just back-set the version to a prior version and then the real message told me what was wrong.
This error is also sometimes caused by a problem with a service and can be caused when the service is not properly registered (with a component or a module) or not properly injected (in a constructor).
Upvotes: 1