angularjs中的$state.current.name和$state.current
我有以下运行块:angularjs中的$state.current.name和$state.current,angularjs,Angularjs,我有以下运行块: app.run(function($rootScope, $ionicLoading,$location,$localStorage,$state, $timeout, $window) { $rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) { if($localStorage.userInfo !== null &
app.run(function($rootScope, $ionicLoading,$location,$localStorage,$state, $timeout,
$window) {
$rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {
if($localStorage.userInfo !== null && toState.name !== 'Deployment' && $state.current.name !== 'Deployment'){
$state.go('Deployment', {}, {reload: true});
console.log($state);
console.log($state.current);
event.preventDefault();
return;
}
});
带有$state
,
它给出:
$current: extend
current: Object
name: "Deployment"
templateUrl: "templates/deployment.html"
url: "/deployment"
__proto__: Object
带有$state.current:
Object {name: "", url: "^", views: null, abstract: true}
$state.current.name
为空,因此条件失败