Angular UI + UI路由器:如何继承已解析状态

时间:2016-05-20 12:58:53

标签: angularjs angular-ui-router resolve

我有一个有三个子州的父州。父状态使用promises检索数据并返回对象中的已解析数据(名为“data”),以便控制器和视图可以访问它。一些子状态还需要已解析的父数据来定义自己的对象命名数据。但似乎从兄弟状态转换时,它们的结算从未到达(相应的状态定义中的断点永远不会被击中)。

简而言之:从状态'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: {
        'setting@settings': {
            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: {
        'tabContent@settings.account': {
            templateUrl: '/app/components/settings/account/views/person.html'
            ,controller: 'AccountController'
        }
    }
})
.state('settings.account.password', {
    url: '/password'
    ,data: ['account',function(account){
        return {
            account: account
        };
    }]
    ,views: {
        'tabContent@settings.account': {
            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: {
        'tabContent@settings.account': {
            templateUrl: '/app/components/settings/account/views/deleteAccount.html'
            ,controller: 'AccountController'
        }
    }
})

1 个答案:

答案 0 :(得分:0)

哎呀..我在州' settings.account.password'中看到了和' settings.account.delete'我忘记了一半的决心......难怪它不会被击中。