0
我有一個擁有3個子狀態的父狀態。父狀態使用promise來檢索數據,並將對象中的已解析數據(名爲'data')返回給控制器和視圖。一些子狀態需要解析父數據來定義他們自己的名爲data的對象。但似乎從兄弟狀態轉換時,它們的解析永遠不會到達(相應狀態定義中的斷點永遠不會被命中)。Angular UI + UI路由器:如何繼承已解決的狀態
簡而言之:從狀態'settings.account.person'轉移到兄弟狀態'settings.account.password'時,我希望執行resolve語句。目前,它沒有被擊中在所有...
國:
.state('settings.account', {
url: '/account'
,resolve: {
menu: ['menu','MenuService', function (menu,MenuService) {
return MenuService.retrieveSubMenuByParentUrl(menu,'/settings/account');
}],
account: ['UserManagementService',function(UserManagementService) {
return UserManagementService.account();
}],
data: ['menu',function (menu) {
return {menu:menu};
}]
}
,views: {
'[email protected]': {
templateUrl: '/app/components/settings/account/views/tabpanel.html'
,controller: 'AccountController'
}
}
})
.state('settings.account.person', {
url: '/person',
resolve: {
languages: ['APIService',function(APIService) {
return APIService.call(AppConfig.API_ENDPOINTS.language);
}],
data: ['menu','account','languages',function(menu,account,languages){
return {
menu: menu,
account: account,
languages: languages
};
}]
}
,views: {
'[email protected]': {
templateUrl: '/app/components/settings/account/views/person.html'
,controller: 'AccountController'
}
}
})
.state('settings.account.password', {
url: '/password'
,data: ['account',function(account){
return {
account: account
};
}]
,views: {
'[email protected]': {
templateUrl: '/app/components/settings/account/views/password.html'
,controller: 'AccountController'
}
}
})
.state('settings.account.delete', {
url: '/delete'
,data: ['account',function(account){
return {
id: account.id
};
}]
,views: {
'[email protected]': {
templateUrl: '/app/components/settings/account/views/deleteAccount.html'
,controller: 'AccountController'
}
}
})
目前您的settings.account.password沒有「解析」,它有一個「數據」,稍有不同。改變它來解決,它可能會工作。 – rrd