1

この投稿を正しく理解していれば、ロードされた最初の状態が名前付きの ui-view を絶対参照する状態である場合、ui-router-extras の deepstate-redirects を使用して、デフォルトの 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) も読み込まれます。には、によって使用されていない ui-view を満たすglobal状態 ( ) への deepstate-redirect があります。そのため、そのテンプレートはデフォルトの ui-view でレンダリングされます。childdialogchild

4

0 に答える 0