Angular 16 - Router outlet activate event

58 Views Asked by At

We migrated our angular application from angular v13 to v16. The component's lifecycle events were working fine in v13, but having an issue in v16 when routing from one component to another.

In our component HTML, there is a router activate event defined. <router-outlet (activate)="activateEvent($event)/> and also an ngOnInit event is defined in component ts file.

Angular v13
When we're trying to do router.navigate from our home page to the above component, the event is fired in below sequence

  1. Component activateEvent is fired
  2. Component ngOnInit is fired

Angular v16
When trying the same thing with a newer version, the sequence of events has changed.

  1. Component ngOnInit is fired
  2. Component activateEvent is fired

As the events are not fired correctly, so causing an issue.

Any help will be appreciated.

The sequence of events of components should be same.

0

There are 0 best solutions below