Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 872
Rafi Ud Daula Refat Avatar asked Dec 24 '15 18:12

Rafi Ud Daula Refat


1 Answers

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.com/angular-ui/ui-router/pull/1867

like image 102
Noam Avatar answered Sep 21 '22 00:09

Noam