castillo-io / angular-css

CSS on-demand for AngularJS [Looking for New Maintainers]
http://castillo-io.github.io/angular-css/#/
MIT License
470 stars 87 forks source link

Its not working with state provider #54

Open alimalik91 opened 8 years ago

alimalik91 commented 8 years ago

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.

scottux commented 8 years ago

Can you provide a code sample of your index.html, app.js, etc.?

alexcastillo commented 8 years ago

Yes, a plunker would help.

cwouter commented 7 years ago

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());
      });
    }]);