启动程序先导入Login元件
ng generate component [component_name]
ng generate module [module_name]
新增login元件、home元件 范例:
ng g c login
ng g c home
新增app-routing模组 范例:
ng g m app-routing
app-routing.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
// 引用的模组、元件
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from '../home/home.component';
import { LoginComponent } from '../login/login.component';
// 建立路由规则
const appRoutes: Routes = [
{ path: '', redirectTo:'login',pathMatch:'full' },
{ path: 'login', component: LoginComponent },
{ path: 'home', component: HomeComponent },
{ path: '**', redirectTo:''}
]
// 模组设定
@NgModule({
declarations: [],
imports: [
CommonModule,
RouterModule.forRoot(
appRoutes, { enableTracing: false }
)
],
exports: [
RouterModule
]
})
export class AppRoutingModule { }
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
// 引用的模组、元件
import { LoginComponent } from './login/login.component';
import { HomeComponent } from './home/home.component';
import { AppRoutingModule } from './app-routing/app-routing.module';
// 模组设定
@NgModule({
declarations: [
AppComponent,
LoginComponent,
HomeComponent
],
imports: [
BrowserModule,
AppRoutingModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
app.component.html
<router-outlet></router-outlet>
ng serve --open --port [XXXX]
范例
ng serve --open --port 9985
出於书本 Chapter 5. Social Engineering 钓出资讯 (Phishing ...
今日目标 认识 nil 认识 Optional 认识 if let 及 guard let nil ...
box-sizing这个语法可以让设计师或是写程序的人不用去加加减减的计算区块 (比如说线条宽度或是...
更多会员限定文章可以到patreon观看 WSLg + Snap 如果清除/snap後还是不能mou...
前言 一开始是为了一些蠢事而做的,至於是什麽蠢事,这边就暂且不提,後来自己看见Meet6机器人的强大...