带有ui路由器的嵌套子状态

Nested child state with ui-router

本文关键字:状态 嵌套 ui 路由器 带有      更新时间:2023-09-26

当我在Angular应用程序上工作时,我想知道ui-route嵌套状态。

正如文档中所说,可以创建嵌套状态,例如(取自文档(:

 $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'
 )}

是的,你可以按照你的建议那样做。例如:

$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'
  });