79365839

Date: 2025-01-17 19:01:09
Score: 0.5
Natty:
Report link

Angular won't re-render the component even with onSameUrlNavigation: 'reload' as per its documentation (https://v17.angular.io/api/router/OnSameUrlNavigation) this is usually used when you want to re-trigger a canMatch guard.

The easiest way is to add a listener to the params subject in Route in your component and wait for changes, then refresh your state.

 
  private async doInit() {
    await this.doMyStuff();
    await this.doAwesomeStuff();
  }

  public async onInit() {
    await this.doInit();
  }

  constructor(
    private readonly route: ActivatedRoute,
  ) {
    this.route.params.subscribe(async (params: Params) => await this.doInit());
  }
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: CommunismForever