ng cli常用的生成代码

常用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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值