1. 安装开发环境
注:如果你的电脑中还没有安装nodejs和npm,请先安装nodejs和npm。确保你的node是6.9.x版本或者以上,npm是3.x.x或以上。
npm install -g @angular/cli
2. 新建项目
ng new my-app
3. 启动
cd my-app
ng serve --open
--open(或者--o)可以自动打开浏览器窗口,默认是http://localhost:4200/
4. 认识框架结构
根目录
my-app
e2e
app.e2e-spec.ts
app.po.ts
tsconfig.e2e.json
node_modules/...
src/...
.angular-cli.json
.editorconfig
.gitignore
karma.conf.js
package.json
protractor.conf.js
README.md
tsconfig.json
tslint.json
src目录
src
app
app.component.css
app.component.html
app.component.spec.ts
app.component.ts
app.module.ts
assets
.gitkeep
environments
environment.prod.ts
environment.ts
favicon.ico
index.html
main.ts
polyfills.ts
styles.css
test.ts
tsconfig.app.json
tsconfig.spec.json