Angular-hello world
环境搭建- 安装angular-cli
用npm安装typescript和typings
npm install -gtypescript typings
安装angular-cl
npm install -gangular-cli@latest
ngnew ProjectName //ProjectName为你的项目名,用此命令建立基本文件,然后强制终止
cd ProjectName
cnpm install //下载node-modules库
ngserve // 启动项目
接下来在浏览器输入http://localhost:4200
PS:使用npm默认从国外网站下载资源,cnpm默认从国内网站下载资源。
angular-cli创建基本文件:
angular-cli.json是angular-cli的配置文件,
测试配置文件karma.conf.js
typescript的lint配置文件
端到端的测试配置文件protractor.conf.js
导入es6模块的配置文件polyfills.ts
angular工程的main.ts引导启动文件
全局样式style.css
typescript配置文件ts.config.json;
typescript的声明文件typings.d.ts
angular组建app.components相关的css,html,ts
这些配置都是angular2的生产项目中需要配置的文件
关键点:
1.添加组件Component
ng g component home
ng g component about
2.添加模块Module
PS:默认下载到G:\Angular2研究\angular-cli-login\src\app
ng g modulehome
ng g module about