angularjs - Injecting $state (ui-router) causes circular dependency -


when put $state there error...how can fix it?

i want use $state navigate page dont know how ? suggestion ? there other way navigate user page ?

 app.factory('mainauthinterceptorservice', ['$q','$state', '$injector', '$location', 'localstorageservice', function ($q,$state, $injector, $location, localstorageservice) {....} 

im using

 authservice.logout(); 

and need redirect user page ...

one simple fix use $injector service reference $state service, so:

    app.factory('mainauthinterceptorservice', ['$q', '$injector', '$location', 'localstorageservice',       function($q, $injector, $location, localstorageservice) {         var $state = $injector.get('$state'); // inject state manually          ... // interceptor logic       } 

you can use $state object usual.

there similar question created user great answer explains issue in depth: injecting $state (ui-router) $http interceptor causes circular dependency


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -