Angularjs 默认为角度UI路由器嵌套视图

Angularjs 默认为角度UI路由器嵌套视图,angularjs,angularjs-routing,angular-ui-router,Angularjs,Angularjs Routing,Angular Ui Router,默认情况下,当我导航到加载主模板的父状态配置文件时,我试图打开状态“profile.general” 当导航到/profile url时,如何激活ui视图的嵌套状态 $urlRouterProvider.otherwise("/profile/general"); $stateProvider.state('profile', { url: '/profile', abtract: true, views: { "main": {

默认情况下,当我导航到加载主模板的父状态配置文件时,我试图打开状态“profile.general”

当导航到/profile url时,如何激活ui视图的嵌套状态

$urlRouterProvider.otherwise("/profile/general");

$stateProvider.state('profile', {
    url: '/profile',
    abtract: true,
    views: {
        "main": {
            controller: 'ProfileCtrl',
            templateUrl: 'src/app/profile/index.tpl.html'
        }
    }
}).state('profile.general', {
    //url: '/register/details',
    templateUrl: 'src/app/profile/profile-general.html'
    //controller: 'ProfileCtrl'
}).state('profile.security', {
    //url: '/register/details',
    templateUrl: 'src/app/profile/profile-security.html'
}).state('profile.social', {
    //url: '/register/details',
    templateUrl: 'src/app/profile/profile-social.html'
}).state('profile.privacy', {
    //url: '/register/details',
    templateUrl: 'src/app/profile/profile-privacy.html'
}).state('profile.payments', {
    //url: '/register/details',
    templateUrl: 'src/app/profile/profile-payments.html'
}).state('profile.restrictions', {
    //url: '/register/details',
    templateUrl: 'src/app/profile/profile-restrictions.html'
});
})
HTML


这些行应该有助于:

$urlRouterProvider.when("/profile", "/profile/general");
$urlRouterProvider.otherwise("/profile/general");
我们应该将
url
赋予一般子状态:

.state('profile.general', {
    //url: '/register/details',
    url: '/general',
    templateUrl: 'src/app/profile/profile-general.html'
因此,有了这些,我们就有了
。。。当用户只针对抽象状态时,会重定向到选定的url

另外,因为我们为一个孩子引入了url,所以我们可以使用
。否则
作为整体默认状态

另一种方法是省略一个子项的url(仅一个子项):


检查配置文件。常规将url设置为
“”
.state('profile.general', {
    //url: '/register/details',
    url: '/general',
    templateUrl: 'src/app/profile/profile-general.html'