O'Reilly logo

Learning Web Development with Bootstrap and AngularJS by Stephen Radford

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Routes with parameters

Okay, we've set up multiple routes but we still need to look at how we can include parameters within them. This is important to allow a level of dynamism within our contacts manager. For example, we're going to be using them to view a specific contact by referencing an ID number or index.

Adding a parameter is easy; we just need to add a placeholder in. This is done with a colon followed by the name of the parameter we wish to create. Let's take a look at the route we're going to make to view our contact. Once more, we can chain this onto our existing routes:

.when('contact/:id', {
    controller: 'contactCtl',
      templateUrl: 'assets/partials/contact.html'
});

We can add as many parameters as required, and it's easy to pull these ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required