0

In app.module.ts I use APP_INITIALIZER to call my initialiser service (ApplicationInitialiserService). This loads data from an api and creates routes dynamically. All these routes target a child component.

When I click the router links to navigate this initialises the targeted component and everything loads fine.

But when I refresh the page it does not load up this child component.

Maybe I need to detect a page refresh and load in the child component? Any suggestions greatly appreciated

Test code - if you go to https://ivw5j6.csb.app/ and click the routerLink to /test it loads and shows "page works" But if you refresh https://ivw5j6.csb.app/test the page component does not load.

1 Answer 1

2

You need to add this.router.initialNavigation(); in your service after adding routes

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.