Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic url routing with angularjs

I have something like that in my code

<ul ng-model="services">
   <p ng-repeat="item in items"><b>{{ item.name }}</b> 
   </p>

I have for example 3 items: BMW, golf and mercedes I want to have an url with the name of each item, like /bmw or /mercedes and all url use details.html to show the details of the selected Item. I'm trying to understand how can I do this.

like image 640
user3235881 Avatar asked Mar 16 '23 17:03

user3235881


1 Answers

You can write a generic route like

.when('/car/:carId', {
  templateUrl: 'some/path/details.html',
  controller: 'someCtrl'
})

And then in the controller you can get the value of :carId using the $routeParams

like image 51
Clyde Lobo Avatar answered Mar 24 '23 05:03

Clyde Lobo