angular-css
angular-css copied to clipboard
Its not working with state provider
Hi,
I added this in my angularjs app, used in a state. In the state, provided the css. But it is loaded in all of the (unrelated) states, instead of just the requisite state.
Can you provide a code sample of your index.html, app.js, etc.?
Yes, a plunker would help.
This has probably nothing to do with the issue of alimalik91. But I can confirm that angular-css doesn't work with the latest version of ui-router. (because of the deprecated $stateChangeSuccess event on the $rootScope)
You could workaround this issue by manually broadcasting a rootScope event:
angular
.module('app')
.run(['$rootScope', '$transitions', ($rootScope, $transitions) => {
$transitions.onSuccess({}, transition => {
// Backwards compatible UI Router
$rootScope.$broadcast('$stateChangeSuccess', transition.to(), transition.params(), transition.from(), transition.params(), transition.options());
});
}]);