Inside the view are controllers for selecting cities and parameters. And in the same view selected objects of the selected cities should be displayed. When the view is loaded, the url is analyzed and a request to the server is made based on the parameters. It is not known in advance exactly which parameters will be chosen. Therefore, the url of the page should be something like this: http://site.com/cities?cityId=3&cityId=33¶m1=value1 . In this regard, the questions:

  1. How to put this url in the right place?
  2. what event to write a handler to catch such a transition?
  • It is not clear why to catch such a transition? the controller is initialized during the transition, and all actions can be done in it - Grundy
  • @Grundy, 99% transitions are performed within the same view. - Denni Adam
  • In general, view does not refer to url. But you just need a minimal reproducible example - Grundy
  • @Grundy, thank you very much, but I have already found a working solution for myself. - Denni Adam 2:57 pm
  • rather workaround :-) - Grundy

1 answer 1

  1. In $ stateProvider

     .state ('cities', {
           url: "/ cities? cityId & cityId & someParam",
           templateUrl: "...."
         })
    
  2. Call:

     $ state.go ('cities', {/ * params * /}, {location: true})
    
  3. It is intercepted and parsed at the event:

     $ rootScope. $ on ('$ stateChangeSuccess', function () {
       console.log ($ location. $$ url)
     }
    
  • why viewContentLoaded and not statechangesuccess ? - Grundy
  • @Grundy, you are right. Corrected. - Denni Adam