我正在研究 ui-router。我有一个状态:
.state('new-personal-orders', {
url: '/orders/new-personal-orders/:catId?',
template: '<new-personal-orders></new-personal-orders>'
})
在我的 Controller 中,我可以使用
$state.go('new-personal-orders',null,{reload:true})
在 Html 文件中我有一个 anchor 标记:
<a href="/orders/new-personal-orders#12">Link</a>
如果标签被点击,状态就会改变,'new-personal-orders' 变成当前状态,在 url 中有尾随散列。然后 url 看起来像:
http://localhost:3000/orders/new-personal-orders#12
我想使用 ui-router 的 $state.go() 函数从 Controller 文件中执行相同的操作。但是没有添加哈希 url。
我的问题是,是否有任何方法可以通过 ui-router 中的 $state.go() 传递哈希 url?
最佳答案
看来你现在可以像这样在状态参数中放置一个散列:
$state.go('new-personal-orders', {'#': catId });
而且您甚至根本不需要在状态配置中使用 /:catId
。
参见 https://github.com/angular-ui/ui-router/pull/1867
关于javascript - 使用哈希 url 卡在 Angular ui-router State.go 上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34456486/