我有这个状态
$stateProvider
.state('app', {
url : '/app',
abstract : true,
templateUrl: 'templates/leftmenu.html',
controller: 'GlobalLeftMenuController'
})
.state('app.home', {
url: '/home',
views: {
'app': {
templateUrl: 'templates/app-home/templates/home.html',
controller: 'AppHomeController'
}
}
});
if(localStorage.userId === undefined || localStorage.userId === '') {
$urlRouterProvider.otherwise('/signup');
} else {
console.log("on otherwise going home");
$urlRouterProvider.otherwise('/home');
}
这里
console.log("on otherwise going home");
$urlRouterProvider.otherwise('/home');
正在执行,但AppHomeController
未加载
答案 0 :(得分:0)
这看起来像应该添加到var pets=[{id:"1",name:"rupert",readyForHome:"No",age:12,personality:["friendly","lazy","loving"]},{id:"2",name:"mrs fluffy",readyForHome:"Yes",age:2,personality:["affectionate","playful","shy"]},{id:"3",name:"tabitha",readyForHome:"Yes",age:4,personality:["aggressive","independent"]},{id:"4",name:"lily",readyForHome:"No",age:8,personality:["friendly","playful","mischievous"]}];
pets = pets.map(function(pet) {
return Number(pet.id);
});
console.log(pets);
的逻辑,这是一个路由事件监听器,可以添加到主模块的$stateChangeStart
块中。
此外,由于您使用的是UI-Router,因此您应该使用.run()
重定向到应用程序中的新路线。
$state.go(name_of_state)