ui-router-extras:DSR和并行状态

时间:2015-08-20 08:52:46

标签: javascript angularjs angular-ui-router angular-ui-router-extras

如果我正确理解this post,我应该能够使用ui-router-extras的deepstate-redirects在默认的ui-view中加载默认模板,当第一个加载状态为绝对状态时引用一个命名的ui-view。

考虑以下示例:

angular
.module( 'app', [ 'ui.router', 'ct.ui.router.extras' ])

.config( function ( $stateProvider ) {
  $stateProvider

  .state( 'global', {
    template: '<div ui-view class="global"><em>empty global state</em></div>',
    deepStateRedirect: {
      default: { state: 'global.parent.child' }
    }
  })

  .state( 'global.parent', {
    template: '<div ui-view class="parent"><em>empty parent state</em></div>',
    sticky: true
  })

  .state( 'global.parent.child', {
    template: 'child view'
  })

  .state( 'global.dialog', {
    views: {
      'dialog@': { template: 'dialog view' }
    }
  });
})

.directive( 'body', function ( $state ) {
  return {
    link: function () {
      // this complies with global's DSR and goes straight to child-state:
      // $state.go( 'global' );

      // shouldn't this comply to global's DSR and show child-state as inactive state?
      $state.go( 'global.dialog' );
    }
  };
});

(plunkr:http://plnkr.co/edit/fuFUFaqUGRjCKfajaWw2?p=preview

如果以上工作,我错过了什么,或者我在这里做了一些错误的假设?

我的推理*

*部分基于我之前提到的帖子

加载dialog状态时,还会加载其父状态(global)。 global具有状态(child)的状态重定向,用于填充dialog未使用的ui视图,因此,child呈现其模板在默认的ui-view中 - 或者这可能有点太好了。

0 个答案:

没有答案