AngularJS UI 路由器链接到状态 URL 状态之间的参数
AngularJS UI Router linking to a State with URL Parameters inbetween the state
我有一些状态路由,例如:
.state. ('home', { ... })
.state('home.company', {
url: 'company/{ID:int}',
abstract: true,
template: '<ui-view/>'
})
.state('home.company.list', {
url: '/list',
views: { ... }
我想使用这样的东西:
ui-sref="home.company({ ID: id }).list"
导航到该州。但它不起作用。我还尝试执行以下操作:
ui-sref="home.company.list({ ID: id })"
这也不行。有什么技巧可以让它发挥作用吗?
P.S。如果我使用过它会起作用:
$state.go(route, { ID: id });
其中 state
将是 'home.company.list'
。但这不是我目前想要实现的。
P.P.S
这是我得到的错误:
Error: Invalid state ref 'home.company({ ID: id }).list>
以上状态好像没问题。我只是稍微调整了一下就可以了。
- 添加了 url 本地状态的 def
- 将
<ui-view />
转换为更常见和受支持的 <div ui-view=""></div>
这是片段
$stateProvider
.state('home', {
template: '<div ui-view=""></div>',
url: "/home"
})
.state('home.company', {
url: 'company/{ID:int}',
abstract: true,
template: '<div ui-view=""></div>',
})
.state('home.company.list', {
url: '/list',
views: {
'': {
templateUrl: 'tpl.html',
}
}
})
这些链接符合预期
<a ui-sref="home.company.list({ ID: 1 })">
<a ui-sref="home.company.list({ ID: 22 })">
检查一下here
我有一些状态路由,例如:
.state. ('home', { ... })
.state('home.company', {
url: 'company/{ID:int}',
abstract: true,
template: '<ui-view/>'
})
.state('home.company.list', {
url: '/list',
views: { ... }
我想使用这样的东西:
ui-sref="home.company({ ID: id }).list"
导航到该州。但它不起作用。我还尝试执行以下操作:
ui-sref="home.company.list({ ID: id })"
这也不行。有什么技巧可以让它发挥作用吗?
P.S。如果我使用过它会起作用:
$state.go(route, { ID: id });
其中 state
将是 'home.company.list'
。但这不是我目前想要实现的。
P.P.S 这是我得到的错误:
Error: Invalid state ref 'home.company({ ID: id }).list>
以上状态好像没问题。我只是稍微调整了一下就可以了。
- 添加了 url 本地状态的 def
- 将
<ui-view />
转换为更常见和受支持的<div ui-view=""></div>
这是片段
$stateProvider
.state('home', {
template: '<div ui-view=""></div>',
url: "/home"
})
.state('home.company', {
url: 'company/{ID:int}',
abstract: true,
template: '<div ui-view=""></div>',
})
.state('home.company.list', {
url: '/list',
views: {
'': {
templateUrl: 'tpl.html',
}
}
})
这些链接符合预期
<a ui-sref="home.company.list({ ID: 1 })">
<a ui-sref="home.company.list({ ID: 22 })">
检查一下here