ui路由器嵌套的子状态
问题描述:
当我在处理一个Angular应用程序时,我想知道ui-route
嵌套状态。ui路由器嵌套的子状态
正如docu说,它可以创建嵌套的状态,如(取自DOC):
$stateProvider
.state('contacts', {
templateUrl: 'contacts.html',
controller: function($scope){
$scope.contacts = [{ name: 'Alice' }, { name: 'Bob' }];
}
})
.state('contacts.list', {
templateUrl: 'contacts.list.html'
});
但是,它可以创建一个granchild状态? (可能加入类似的东西):
.state('contacts.list.state', {
templateUrl: 'html_file.html'
)}
答
是的,你可以按照你的建议像那样做。 EG:
$stateProvider
.state('contacts', {
url: '/',
templateUrl: 'contacts.html',
controller: function($scope){
$scope.contacts = [{ name: 'Alice' }, { name: 'Bob' }];
}
})
.state('contacts.list', {
url: ':list',
templateUrl: 'contacts-list.html'
})
.state('contacts.list.fullDetails', {
url: '/fullDetails',
templateUrl: 'contacts-list-full-details.html'
});
谢谢!我还有另外一个问题(也许我应该在第一个编辑中包含它或者创建一个新的主题)。我想使用具有动态子状态的父状态。状态将是'contact.state'与这个URL'/:state'。由于孙儿状态是可能的,我认为在这种情况下应该可以。我是对的吗? – Arhyaa
@Arhyaa嘿!是的,你可以做这样的动态URL:'url:'/ contact /:someId'' –
我会尝试使用它,非常感谢:) – Arhyaa