命令行单词 new generate module component serve service pipe 可以用缩写
命令行ng g + fileName
生成文件,驼峰式命名的 fileName 最终将会变为 file-name
命令行ng g file-name --module=app-name
指明所属模块时,模块要用 app-name 的形式指明
1 2 3 4
| ng g m module-name
ng g m module-name --routing
|
1 2 3 4
| ng g m app-routing --module=app --flat
|
1 2 3 4 5 6 7 8 9 10
| import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router';
const routes: Routes = [];
@NgModule({ imports: [RouterModule.forChild(routes)], exports: [RouterModule] })
|
1 2 3 4 5
| ng g c component-name --module=app
ng g s component-name
ng g p string-slice --module=app
|
1 2 3
| ng s --host
ng s --port 3001
|