angular命令集

npm install -g @angular/cli 安装angular cli脚手架

npm install -g cnpm 安装淘宝镜像

npm uninstall -g @angular/cli 卸载angular cli

npm cache clean 清除缓存

cnpm install -g @angular/cli npm 淘宝镜像方式重新安装

ng -v 查看版本/检验是否安装成功

ng new progect 创建新项目

进入项目目录
cnpm install / npm install 安装依赖

ng serve --open 启动项目

ng serve --port 1234 更改默认端口号

ng serve --host 192.168.1.1 将服务发到局域网中

ng generate component example 生成组件带有模版

ng generate component example -it 生成内联模版(不会单独生成html文件)

ng generate directive my-directive - 生成一个新指令

ng generate pipe my-pipe - 生成一个新管道

ng generate service my-service - 生成一个新服务

ng generate route my-route - 生成一个新路由

ng generate class my-class - 生成一个简易的模型类

简写

ng g cl my-new-class 新建 class
ng g c my-new-component 新建组件
ng g d my-new-directive 新建指令
ng g e my-new-enum 新建枚举
ng g m my-new-module 新建模块
ng g p my-new-pipe 新建管道
ng g s my-new-service 新建服务

以下可能常用的命令参数有:

–flat 表示是否不需要创建文件夹

–inline-template (-it) 模板是否应该放在ts文件里

–inline-style (-is) 样式是否应该放在ts文件里.

–spec 是否需要创建spec文件(测试文件)

–view-encapsulation (-ve) View Encapsulation策略 (简单理解为样式文件的作用范围策略).

–change-detection (-cd) 变化检查策略.

–prefix 设定这个component的前缀

–dry-run (-d), 打印出生成的文件列表, 而不直接生成.

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值