常用ng cli生成文件代码
ng g c
–flat 默认为false,当为true时,将直接创建文件而不创建文件夹。
–skipTests 别名-S(创建初始项目时有效) 不创建.spec.ts文件。(通用)
–inlineStyle=true|false 别名-s
–inlineTemplete=true|false 别名 -t
–prefix=prefix 别名-p 修改selector (‘app-root’)前缀
–project=project 指定当前工作区间内的某个项目名称
–selector=selector 指定selector名称
–skipImport=true|false 为true时不会import到ngModule中
–skipSelector=true|false 不会生成selector
–viewEncapsulation=Emulated|Native|None|ShadowDown 别名-v 视图封装策略使用在新创建的组件上;
ng g enum 生成可枚举类
ng g guard [options] 生成一个路由守卫,可导入钩子函数
ng g interceptor [options] 生成拦截器
ng g interface 生成接口
ng g library [options]在当前工作区间生成一个project library
ng g module [option] 创建一个新的模块
–route=route The route path for a lazy-loaded module.When supplied,creates a component in the new module,and adds the route to that component in the Routes array declared in the module provided in the --module option.
–routing=true|fasle 为true,创建一个路由模块
–module=module 别名-m 指定模块
–routingScope=Child|Root 新路由模块的范围
–lintFix=ture|fasle
****(ng g module app-routing --flat --module app)在没有路由模块的情况下生成app-routing文件。配置文件时需要 exports: [RouterModule]。不然会报错.
****添加英雄管理功能(HeroesModule)ng g module heroes/heroes --module app --flat --routing
ng g pipe 生成管道
–export 在NgModule中exports这个pipe
ng g service 生成服务
ng g serviceWorker [options] 不知道什么用(装了packages,update app.module.ts)
ng g webWorker
ng g appShell
ng g application
ng g class