angularjs - Angular UI-Router: Can't access state name from service -
i want detect name of current state service.
problem: $state.current.name
returns null.
app.factory('rootuserservice', ['$http', '$state', '$stateparams', '$rootscope', '$q', 'socketfactory', function($http, $state, $stateparams, $rootscope, $q, socketfactory) { return { guestornot: function(res) { if ( res._id === 'someid' ) { $rootscope.isguest = true; } else { $rootscope.isguest = false; // if current state = app.landing, something. console.log($state) // current.name field 'app.landing' console.log($state.current) // name field empty console.log($state.includes('app.landing')) // returns false no matter what. }; } }]);
console.log($state) returns below:
console.log($state.current) returns below
Comments
Post a Comment