javascript - 使用哈希 url 卡在 Angular ui-router State.go 上?

标签 javascript angularjs hash angular-ui-router angular-ui

我正在研究 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/

相关文章:

javascript - 如果找到值,则返回解析为 bool 值 true 或 false 的 promise

python - 类型错误 : a float is required in sklearn. feature_extraction.FeatureHasher

c - c-Hash Map实现在相同的valgrind错误上停留了4天(通过不协调的屏幕共享获得帮助吗?)

javascript - 通过在 angularjs 中单击按钮发送要由服务器安装的文件名称

javascript - AngularJS数据绑定(bind)不动态更新内容

javascript - 使用 $http 制作 Angular 过滤器?

javascript - AngularJS 输入值作为数组与模型不匹配

c# - ruby 和 C# 之间 SHA 哈希的差异

javascript - 在 Ajax 成功时强制下载 .mp3 或 .zip 文件

javascript - 使用 jQuery.extend() 进行覆盖时如何包含对原始函数的引用