Angular 4.0从入门到实战

 

#安装Angular CLI 脚手架工具,如无权限则前加sudo

 

$ npm install -g @angular/cli 
 

 

#或使用淘宝库

 

$ npm install -g cnpm --registry=https://registry.npm.taobao.org
 

 

#安装Angular CLI 脚手架工具

 

$ cnpm install -g @angular/cli

 

 

如安装angular/cli失败,则卸载,清除缓存,重新安装

    #卸载angular/cli

 

$ npm uninstall -g @angular/cli
  

 

    #清除缓存

 

$ npm cache clean
 

 

    #重新安装

 

$ cnpm install -g @angular/cli
    #查看版本能否正常显示
$ ng -v
 
   #创建项目,新建项目名
$ ng new angulardemo
   #进入所建目录启动服务
$ cd angulardemo
    #安装依赖
$ npm install
    #启动服务
$ ng serve --open
 
工程目录结构及说明: 
  • .editorconfig webstrom配置文件
  • karma.conf.js 自动化单元测试配置文件
  • protractor.conf.js 自动化单元测试
  • tslint 代码规范监测
  • src 
    • app 应用的组件和模块 
      • 模块
      • 组件
    • assets 静态资源
    • environments 环境配置 (多环境,开发,测试,生产)
    • index 根文件
    • main.ts 脚本执行的入口点(启动项目)
    • polyfills 导入一些必要的库,支持老版本的ag
    • css 全局样式
    • test 自动化测试
    • tsconfig TypeScript编译器

Angualr CLI提供了许多常用命令:

    ng generate class my-new-class              // 新建 class

    ng generate component my-new-component      // 新建组件

    ng generate directive my-new-directive      // 新建指令

    ng generate enum my-new-enum                // 新建枚举

    ng generate module my-new-module            // 新建模块

    ng generate pipe my-new-pipe                // 新建管道

    ng generate service my-new-service          // 新建服务

 

    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       // 新建服务 

 

    Angular 4.0从入门到实战: https://blog.csdn.net/qq_33936481/article/details/73622207

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值