Routing in Angular

As we saw in Chapter 3, Angular Building Blocks - Part 2, Angular introduced a component router that deep links the URL request, maps the component that is annotated for this route, and renders the template or view associated with the component. The Angular router is not part of the core Angular framework. It comes as part of the Angular router module. We need to add the reference to this library in package.json, as follows, under the dependencies section:

"dependencies": {"@angular/router": "~4.0.0",}

Then, we need to add the <base> element under <head> to instruct the router to set up navigation URLs. The following code snippet shows the <base> tag with the href attribute that should be added to the head tag in the ...

Get Learning Angular for .NET Developers 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.