Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

styles file doesn't get loaded when using the $state.go #5

Closed
yahyaKacem opened this issue Jan 14, 2015 · 0 comments
Closed

styles file doesn't get loaded when using the $state.go #5

yahyaKacem opened this issue Jan 14, 2015 · 0 comments

Comments

@yahyaKacem
Copy link

Hi, thanks for this, I got this error when I have state profile with default nested state about and configuring the ui-router to redirect to profile.about when profile state is requested the styles files doesn't get loaded unless I click on the link or the about state directly or reload the page here's a plunker with the error.

Update

After further investigation, using this better plunker the acctual problem was not calling the $state.go directly it was having a nested states with default child state, due to this bug on ui-router I had to use the hack mentioned there to navigate to the child state with this code:

$rootScope.$on('$stateChangeStart', function (event, toState) {
  var url, routeRegex;
  routeRegex = /^profile$/;
  if (routeRegex.test(toState.name)) {
    event.preventDefault();
    url = toState.name + '.about';
    $state.go(url);
  }
});

That code runs when navigating directly to the parent profile state which have the profile.about as default state, by clicking on the profile link on the navigation like this:

ui_router_style_loading_error

as seen in the picture the profile.about state data object gets redefined by the parent profile state because of when the code above gets run the order of defining the data.css attribute of the state config object gets changed so the data of the child state gets defined before the data from the parent child which means the child's state data gets overwritten by the parent data, so this is probably a bug with the ui-router not the this plugin.
And when navigating with the correct state name profile.about everything works as expected:
when we go to the profile.feed state by clicking the link for it:

feed

Then going back to the profile.about state using the link for it not the profile one:

about

I may just use the parent to handle all the CSS for children for now, I can see any other solution.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant