Skip to main content

Angularjs RouteParams with ngRoute

Points To Remember


  • You should pass the params separated by "/".
  • You can pass the params to the controller and pass them to the templates or apply logic.
  • You need to add $routeParams input to your controller function to get these params.

How to pass Params from one state to another in AngularJs using ngRoute.

You need to add the route params along with the url e.g you can send the params as follows

 #url/param1/param2


This is how you can update your $routeProvider to use these route params.
Finally, access the params in the controller and pass them to the template.

Putting everything together the code will work as shown in the plunk below.

Comments