Passing multiple parameters along an AngularJS route

I am trying to implement an angular route that should have several parameters. Here is an example of what I tried:

.when('/myRoute/paramA/:paramA/paramB/:paramB/paramC/:paramC', { templateUrl: 'abc.html', controller: 'pwrController as pwrCtrl' }); 

Now the problem is that I need to always pass paramA in order to pass paramB. Both paramA and paramB to pass paramC.

Is there any way in angular where I can pass paramA, paramB or paramC on my own?

Thanks.

+5
source share
1 answer

enter $location in your controllers and use this instead of routeParams

 var paramA = 'something'; $location.search('paramA', paramA); // write // result http://localhost:3000/#/route/routeParam?paramA=something $location.search() // read whole object $location.search().paramA // read one parameter // result 'something'; 
+13
source

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


All Articles