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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.