Creating dashboard in angular tutorial
A Dashboard is a page or a user interface in which information and other functions/pages of a website is provided in such a way that is easily accessible, understandable and readable. So in this tutorial, I am providing 4 Quick Steps to Create Dashboard in AngularJS Application.
Step 1:- Create a new application using following command.
ng new my-app
Step 2:- Create separate components for your options like “About us page”, “contact us page”, “help page” etc.
Eg.
import { Component } from '@angular/core';
@Component({
selector: 'app-registration',
templateUrl: './registration.component.html',
styleUrls: ['./app.component.css']
})
export class RegistrationComponent {
title = 'registration';
registerSubmit() {
console.log("resgister clicked");
};
}
Similarly create all your components
Step 3:- Inside your app module.ts file create route as follows.
const appRoutes: Routes = [
{ path: '', redirectTo: '', pathMatch: 'full' },
{ path: 'registration',component: RegistrationComponent },
{ path: '**',component: LoginComponent }
]
NOTE :- For creating route you need to import the proper packages as well so dont forget to mention these imports at the top of your file.
import { RouterModule,Routes } from '@angular/router';
import { name of your component } from 'path of your ts flie;
Step 4:- Now inside your html file of the main component add router links.
eg
<li><a [routerLink] = "['/LoginComponent']">Login</a></li>
This way clicks will be redirected to the corresponding page.
That's all save your code and run it. If you have any questions, please feel free to write in comments.
Happy Coding :)
0 Comment(s)