[Angular UI-Router]:参考当前状态

时间:2017-01-10 15:49:44

标签: angularjs angular-ui-router

如UI-Router文档所述,您可以使用relative and absolute names to refer to a named view

简而言之:

.state('contacts.detail', {
  views: {
    // Absolutely targets the 'content' view in root unnamed state.
    'content@': {},
    // Relatively targets the 'detail' view in this state's parent state, 'contacts'.
    'detail': {}
    // Absolutely targets the 'detail' view in this state's parent state, 'contacts'.
    // It's the absolute version of the relative one above.
    'detail@contacts': {}
  }
});

因此,相对名称的目标是状态的视图。

要定位当前状态的命名视图,您必须使用如下的绝对名称:

.state('contacts.detail', {
  views: {
    'info@contacts.detail': {}
  }
});

问题是:
是否可以使用相对名称来定位当前状态的命名视图?
OR
是否有任何快捷方式可用于当前状态的绝对名称,因此您不必写出@ - 符号后面的状态的全名? 像info@.而不是info@contacts.detail

1 个答案:

答案 0 :(得分:1)

从angular-ui-router 1.0.0-rc.1开始,您无法轻松定位当前状态的视图。

但是,下一个版本将允许使用"view@."从当前状态定位`“。

请参阅https://github.com/ui-router/core/issues/25(以及测试:https://github.com/angular-ui/ui-router/commit/6f2f4ab55475cd8fb533e53414a64574226be502

相关问题