add component in angular router
First you need to make component using 'ng generate'
$ ng generate component home
$ ng generate component about
Next, in the src/app/app-routing.module.ts file import the components as follows:
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from './home/home.component';
import { AboutComponent } from './about/about.component';
Next, add the routes as follows:
const routes: Routes = [
{ path: 'home', component: HomeComponent },
{ path: 'about', component: AboutComponent }
];
So now if you visit the /home path you should go to home component and if you visit the /about path you should go to the about component.
/*
I hope it will help you.
Namaste
Stay Home Stay Safe
*/
Also in JavaScript:
- Add object to array javascript
- jquery add option to select
- statusbar reactnati
- cannot read property 'props' of undefined react redux functional component
- collection.ensureIndex is deprecated
- jquery checkbox unchecked
- adding cors in angular
- how to cause a whole page reload react redux
- .gitignore nodejs
- array javascript
- javascript set and get cookie
- angular 8 how to iterate json object in view
- founder of javascript
- random item from array javascript
- change view port of svg with javascript
- generate random password
- go to next route vuejs
- javascript login system
- javascript indexof with condition
- check data type in js
- registeing components in vue
- bootstrap validator password and confirm password
- how to clear state in react hooks
- joi in node and express