最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Stuck at Anglular ui-router State.go with hash url? - Stack Overflow

programmeradmin1浏览0评论

I am working on ui-router. I have a state:

.state('new-personal-orders', {
    url: '/orders/new-personal-orders/:catId?',
    template: '<new-personal-orders></new-personal-orders>'
})  

In my controller i can make the state call with the

 $state.go('new-personal-orders',null,{reload:true})   

In the Html File i have an anchor tag:

<a href="/orders/new-personal-orders#12">Link</a>

If the tag is clicked the state changes and 'new-personal-orders' turns into the current state with the trailing hash in the url. The url then looks like:

http://localhost:3000/orders/new-personal-orders#12

I want to do the same from the controller file with the $state.go() function of ui-router. But the hash url is not added.

My question is that is there any way that the hash url can be passed by the $state.go() in ui-router?

I am working on ui-router. I have a state:

.state('new-personal-orders', {
    url: '/orders/new-personal-orders/:catId?',
    template: '<new-personal-orders></new-personal-orders>'
})  

In my controller i can make the state call with the

 $state.go('new-personal-orders',null,{reload:true})   

In the Html File i have an anchor tag:

<a href="/orders/new-personal-orders#12">Link</a>

If the tag is clicked the state changes and 'new-personal-orders' turns into the current state with the trailing hash in the url. The url then looks like:

http://localhost:3000/orders/new-personal-orders#12

I want to do the same from the controller file with the $state.go() function of ui-router. But the hash url is not added.

My question is that is there any way that the hash url can be passed by the $state.go() in ui-router?

Share Improve this question edited Dec 24, 2015 at 18:30 Rafi Ud Daula Refat asked Dec 24, 2015 at 18:13 Rafi Ud Daula RefatRafi Ud Daula Refat 2,25720 silver badges28 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 9

It seems that you can now put a hash in the state params like so:

$state.go('new-personal-orders', {'#': catId });

And you don't even need a /:catId in the state configuration at all. See https://github./angular-ui/ui-router/pull/1867

You can pass state params as an argument in $state.go :

$state.go('new-personal-orders', {catId: 12}, {reload:true})  
// refers to: http://localhost:3000/orders/new-personal-orders/#12

It seems that you are attempting to implement the same inside an ng-repeat, then you should replace 12 by something such as order.catId etc.

发布评论

评论列表(0)

  1. 暂无评论