将
ui-router有解决方案 _(几乎)_任何东西。有一个工作的plnkr。我们将要使用的功能称为:绝对路线(^)
因此,让我们从需求开始,拥有以下URL路由:
domain/#/ -- root for maindomain/#/emergency/ -- main.emergencydomain/#/emergency/detail -- main.emergency.detail
使用此
ui-sref状态调用时哪个应该工作:
<ul> <li><a ui-sref="main">Main</a></li> <li><a ui-sref="main.emergency">Emergency</a></li> <li><a ui-sref="main.emergency.detail">Detail</a></li></ul>
现在,诀窍是:
- 根 (第一) 状态必须使用
url: "/"
,以具有一些唯一标识 - 但是下一个状态可以再次从根开始定义:使用此设置:
url: "^/..."
这是状态配置,可实现所需的结果
$stateProvider // root with '/' .state("main", { url: "/", templateUrl: 'main.tpl.html', }) // here we start again from the root '/emergency' .state("main.emergency", { url: "^/emergency", templateUrl: 'emergency_menu.tpl.html', }) // parent and child '/emergency/detail .state("main.emergency.detail", { url: "/detail", templateUrl: 'emergency_detail.tpl.html', });
这是文档:
[绝对路线(^)](https://github.com/angular-ui/ui-router/wiki/URL-Routing#absolute-routes-)
…还有正在工作的 pl夫 …
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)