How to cause a state after a change of location?

I have a problem. I want to enter the state of another controller. I know that in this case I need to change the location to load this other controller, but how do I tell it to enter this state?

And what’s important, I don’t want to do it globally because I know I can do $rootScope.$on('$locationChangeSuccess', function(e, newUrl, oldUrl){});it and it will work, but this time I want to do it only this time.

Has anyone had a similar problem? or have any ideas how I can do this?

@edit Additional information that may help:

I have more than one state, and the default state is not the one I want to enter. I cannot call $ state.go () because it will load this state in my current controller, and this is not the effect I want to achieve. So that’s why I need to change location and state

+4
source share
1 answer

I don’t know if I understand it correctly ...

Usually you define a state like this:

$stateProvider
.state('party', {
   url: '/party',
   templateUrl: 'party.html'
});

Frome the docs:

There are three main ways to activate a state:

  • Call $ state.go (). High level convenience method.
  • Click the link containing the ui-sref directive
  • Go to state related URL

, `$ state.go( "party" ) . ,

<a ui-sref="party">Go To Party</a> , - , .

$location /party .

0

Source: https://habr.com/ru/post/1613332/


All Articles