May 10, 2020
Estimated Post Reading Time ~

Angular 2: How to set up routing

In order to set up routing in Angular, there are few setup steps.

Include the Angular 2 router script
Define the base element
Register ROUTER_PROVIDERS
Add the Angular 2 Router script to your index.html

//node_modules/angular2/bundles/router.dev.js

or

https://cdnjs.cloudflare.com/ajax/libs/angular.js/2.0.0-alpha.34/router.dev.js
also in the index.html right below the openingtag add this code:

Next, you will need to include ROUTER_PROVIDERS to your main app.component.ts

import { ROUTER_PROVIDERS } from 'angular2/router';
and also don’t forget to register providers. In the @Component({}) provider

ROUTER_PROVIDERS


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.