How to use state.go instead of href?


#1

Hello
I am using href="#/tab/locations/" .But I want to user $state.go(’’);
I have used $state.go(’/tab.locations’);. But it is not working.

Please help me


#2

Pass the state name, not the url.


#3

Yes you can do it like encodedmirko said, but i had some issues with backview and i came up with diy solution i created a service to go to states and store the last views and works pretty well using localforage as history storage .


#4

Hello encodedmirko,
How to do it?

Please helpe me…


#5

your state:

.state('myState', {
   url: '/myState/:param1'
   ....
});

then you need do it so in your controller:

$state.go('myState', {
  param1: 'myParam1Value'
});

in your templates use ui-sref:

<a ui-sref="myState({
  param1: 'myParam1Value'
})">GoTo myState</a>