- Hands-On Data Structures and Algorithms with JavaScript
- Kashyap Mukkamala
- 257字
- 2021-06-30 19:12:10
Laying out the UI
We will use angular-material to style the app, as it is quick and reliable. To install angular-material, run the following command:
npm install --save @angular/material @angular/animations @angular/cdk
Once angular-material is saved into the application, we can use the Button component provided to create the UI necessary, which will be fairly straightforward. First, import the MatButtonModule that we want to use for this view and then inject the module as the dependency in your main AppModule.
The final form of app.module.ts would be as follows:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MatButtonModule } from '@angular/material';
import { AppComponent } from './app.component';
import { RouterModule } from "@angular/router";
import { routes, navigatableComponents } from "./app.routing";
import { Stack } from "./utils/stack";
// main angular module
@NgModule({
declarations: [
AppComponent,
// our components are imported here in the main module
...navigatableComponents
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
// our routes are used here
RouterModule.forRoot(routes),
BrowserAnimationsModule,
// material module
MatButtonModule
],
providers: [
Stack
],
bootstrap: [AppComponent]
})
export class AppModule { }
We will place four buttons at the top to switch between the four states that we have created and then display these states in the router-outlet directive provided by Angular followed by the back button. After all this is done, we will get the following result:
<nav>
<button mat-button
routerLink="/about"
routerLinkActive="active">
About
</button>
<button mat-button
routerLink="/dashboard"
routerLinkActive="active">
Dashboard
</button>
<button mat-button
routerLink="/home"
routerLinkActive="active">
Home
</button>
<button mat-button
routerLink="/profile"
routerLinkActive="active">
Profile
</button>
</nav>
<router-outlet></router-outlet>
<footer>
<button mat-fab (click)="goBack()" >Back</button>
</footer>
推薦閱讀
- 手機(jī)安全和可信應(yīng)用開發(fā)指南:TrustZone與OP-TEE技術(shù)詳解
- Getting Started with Gulp(Second Edition)
- 深入理解Bootstrap
- HTML5 移動(dòng)Web開發(fā)從入門到精通(微課精編版)
- Instant QlikView 11 Application Development
- Linux環(huán)境編程:從應(yīng)用到內(nèi)核
- Mastering KnockoutJS
- 精通Linux(第2版)
- INSTANT Sinatra Starter
- Android群英傳
- Emotional Intelligence for IT Professionals
- OpenCV with Python Blueprints
- Microsoft Exchange Server 2016 PowerShell Cookbook(Fourth Edition)
- Android初級應(yīng)用開發(fā)
- 計(jì)算機(jī)系統(tǒng)解密:從理解計(jì)算機(jī)到編寫高效代碼