Reyraa
Reyraa

Reputation: 4274

how to use a single controller for multiple routes

how to assign a couple of controller and view to multiple route patterns in AngularJS? for example I have a couple of view and controller:

{
  templateUrl: '/partial/single-item.html',
  controller: 'SingleItemController'
}

witch I want them for two routes:

/car/:id
/bike/:id

Upvotes: 1

Views: 69

Answers (1)

mfrachet
mfrachet

Reputation: 8922

You can have a route like : /:myRoute/:id And test in the controller(or in a route regex) the value of myRoute for example

Upvotes: 1

Related Questions