Search code examples
angularjsangular-ui-routerui-sref

ui-sref fires before loading the dynamic states. How to stop this?


Hi I am trying to load states dynamically through an ajax request in the app.run() method. In the same page, I have a link with ui-sref pointing to this dynamic state.

While loading the page, the ui-sref fires before this load and says state not found. Any trick how we can overcome this?


Solution

  • Don't retrieve the states in app.run. Only bootstrap your app after the ajax request is returned.