Nested child state with ui-router

故事扮演 提交于 2019-12-11 19:33:39

问题


As I'm working on an Angular app, I was wondering about ui-route nested states.

As said in the docu, it's possible to create nested state such as (taken from the doc) :

 $stateProvider
   .state('contacts', {
     templateUrl: 'contacts.html',
     controller: function($scope){
       $scope.contacts = [{ name: 'Alice' }, { name: 'Bob' }];
     }
   })
   .state('contacts.list', {
     templateUrl: 'contacts.list.html'
   });

But is it possible to create a granchild state ? (possibly by adding something like) :

 .state('contacts.list.state', {
   templateUrl: 'html_file.html'
 )}

回答1:


Yes, you can do it like that, as you suggested. 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'
  });


来源:https://stackoverflow.com/questions/31206538/nested-child-state-with-ui-router

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!