In the process of creating a testing platform for students to take tests, I encounter an issue with navigation in my TestComponent
. Upon initialization, I retrieve the complete test from a service and then attempt to route to either the questions or instruction component based on the current state of the test (paused or starting for the first time).
Despite resolving the promise returned by this.router.navigate
, the navigation does not function as expected. Interestingly, when I enclose my navigation code within a setTimeout
function, even with a delay of 0 milliseconds, it successfully navigates.
I seek guidance on how to address this challenge and insights into why proper navigation is hindered. My examination of the router's code has yielded no relevant information so far. This pertains to the final release of Angular2.
TL;DR
this.route.navigate
is malfunctioning during the OnInit
phase of the component.
@angular/router: 3.0.0
@angular/common: 2.0.0