Using Angular’s Router for User Navigation

Like Rails, Angular has a way to support navigation-by-URL. Because Angular’s design ethos is based around flexibility, an Angular app isn’t required to use the router, though in most cases you would, and would set it up from the start. We didn’t initially, just to keep our introduction to Angular as simple as possible and reduce the number of new concepts you had to absorb.

Now, we’ll need to convert our existing Angular app to use the router.

Currently, our Angular app hard-codes both the view and the controller. The view is hard-coded by virtue of having all the HTML inside <article ng-app='customers'>. The controller is hard-coded by the use of the ng-controller directive. We’ll break that hard-coding ...

Get Rails, Angular, Postgres, and Bootstrap now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.