javascript - `angular-ui-router` 如何确定在哪里插入状态 View ?

标签 javascript angularjs angular-ui-router

我按照 the github page 上的示例进行操作Angular-ui-router 的。该示例运行良好,但我很困惑 ui-router 如何确定在何处插入部分状态 View 。关于Dive Deeper页面,上面写着

When a state is activated, its templates are automatically inserted into the ui-view of its parent state's template. If it's a top-level state—which 'contacts' is because it has no parent state–then its parent template is index.html.

但是,在我遵循的示例中,我找不到任何指示状态之间的父子关系的信息。例如,state1.list 的父级是什么?为什么?

非常感谢。

最佳答案

层次结构由点表示法确定

来自the docs, Nested States & Nested Views :

You can use dot syntax to infer your hierarchy to the $stateProvider. Below, contacts.list becomes a child of contacts.

$stateProvider
  .state('contacts', {})
  .state('contacts.list', {});

所以 state1.list 的父级是 state1 因为 ui-router 使用点表示法来确定父子关系。

关于javascript - `angular-ui-router` 如何确定在哪里插入状态 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21965557/

相关文章:

javascript - Angular 作用域单例

Angular2 路由器 VS ui-router-ng2 VS ngrx 路由器

javascript - JqueryMobile Div 转换

javascript - jQuery 将 url 加载到 div 中并替换当前内容将 url 传递给函数

javascript - 从顶部动态添加元素并从底部删除相同数量的元素

javascript - 在 jQuery 的 Deferred 对象中抛出错误

css - 使此表列宽度适合。不太宽也不太窄

angularjs - 为什么要给 "abstract: true"状态一个 url?

javascript - 多菜单级别 Angular js

javascript - 为什么这个 Angular 日期选择器不会出现并正常工作?