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: enter image description here

console.log($state.current) returns below enter image description here


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -