angular.js - ui-router 视图嵌套时如何指定二级视图显示默认页面?
我想大声告诉你
我想大声告诉你 2017-05-15 17:09:45


具体的情况是这样的,现在一个问题是:当跳转到user页面时,右边的uiview是为空的,要点击了左侧的导航才能插入模板,如何在路由中设置二级视图的默认显示页面呢?
上代码:
`$stateProvider

.state('user', {
    url: '/user',
    views: {
        '': {
           templateUrl: 'public/front/temphtml/usercenter/userindex.html' 
        }
    }  
})
.state('user.a', {
    url: '/a',
    views: {
       'content@user': {
           templateUrl: 'public/front/temphtml/usercenter/a.html',
           controller: 'userCtrl'
       } 
    }
})
.state('user.b', {
    url: '/b',
    views: {
       'content@user': {
           templateUrl: 'public/front/temphtml/usercenter/b.html',
           controller: 'userCtrl'
       } 
    }
})`
我想大声告诉你
我想大声告诉你

reply all(7)
阿神

已测试,可以解决你的问题。
.state('user', {

url: '/user',
views: {
    '': {
       templateUrl: 'public/front/temphtml/usercenter/userindex.html' ,
       controller: function($state){
            $state.go('user.a');//默认显示第一个tab
        }
    }
}  

})
.state('user.a', {

url: '/a',
views: {
   'content@user': {
       templateUrl: 'public/front/temphtml/usercenter/a.html',
       controller: 'userCtrl'
   } 
}

})
.state('user.b', {

url: '/b',
views: {
   'content@user': {
       templateUrl: 'public/front/temphtml/usercenter/b.html',
       controller: 'userCtrl'
   } 
}

})`

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!