angularJS nested abstract views

2019-04-29 03:14发布

I am using StateProvider library to create nested views in my AngularJS app. I had an abstract view defined at the root and now need to define another abstract view as 2nd level child to the previously created abstract view.

Facing issues with this, Not sure if I can have nested abstract views or not. Any idea.

greatly appreciate your help.

Thanks

1条回答
SAY GOODBYE
2楼-- · 2019-04-29 03:57

There could be more abstract-nested states in hierarchy. This example shows it in action, definition of these states could be like this:

$stateProvider
  .state('main', {
      url: "",
      abstract: true,
      templateUrl: 'tpl.main.html',
  })
  .state('main.middle', {
      url: "",
      abstract: true,
      templateUrl: 'tpl.middle.html',
  })
  .state('main.middle.alpha', {
      url: "/alpha",
      templateUrl: 'tpl.leaf.html',
      controller: function ($scope, $state){
        $scope.state = $state.current;
      },
  })

Check the plunker. As we can see, the root (main) and its child (middle) do not use url at all... but they could..

查看更多
登录 后发表回答