开发工具
- Git && GitHub(这个需要配置好)
- NodeJS && NPM(官网可以安装)
- Visual Studio Code(很赞的编辑器)
- Chrome(推荐,Angular2在IE上有时候没有效果)
搭建QuickStart应用
在环境配置方面,官方在GitHub上给出了一个 QuickStart 的应用框架,可以作为基本的应用框架来使用,用起来很方便。点击下载QuickStart源码 开始吧。
为了方便,我直接粘贴在这里,有删减,翻译水平有限就不翻译了......
Angular 2 QuickStart Source
This repository holds the TypeScript source code of the angular.io quickstart,
the foundation for most of the documentation samples and potentially a good starting point for your application.
It's been extended with testing support so you can start writing tests immediately.
This is not the perfect arrangement for your application. It is not designed for production.
It exists primarily to get you started quickly with learning and prototyping in Angular 2
We are unlikely to accept suggestions about how to grow this QuickStart into something it is not.
Please keep that in mind before posting issues and PRs.
Create a new project based on the QuickStart
Clone this repo into new project folder (e.g., my-proj
).
git clone https://github.com/angular/quickstart my-proj
cd my-proj
We have no intention of updating the source on angular/quickstart
.
Discard everything "git-like" by deleting the .git
folder.
rm -rf .git
Create a new git repo
You could start writing code now and throw it all away when you're done.
If you'd rather preserve your work under source control, consider taking the following steps.
Initialize this project as a local git repo and make the first commit:
git init
git add .
git commit -m "Initial commit"
Create a remote repository for this project on the service of your choice.
Grab its address (e.g. https://github.com/<my-org>/my-proj.git
) and push the local repo to the remote.
git remote add origin <repo-address>
git push -u origin master
Install npm packages
Install the npm packages described in the package.json
and verify that it works:
Attention Windows Developers: You must run all of these commands in administrator mode
npm install
npm start
The npm start
command first compiles the application,
then simultaneously re-compiles and runs the lite-server
.
Both the compiler and the server watch for file changes.
Shut it down manually with Ctrl-C.
You're ready to write your application.
npm scripts
We've captured many of the most useful commands in npm scripts defined in the package.json
:
-
npm start
- runs the compiler and a server at the same time, both in "watch mode". -
npm run tsc
- runs the TypeScript compiler once. -
npm run tsc:w
- runs the TypeScript compiler in watch mode; the process keeps running, awaiting changes to TypeScript files and re-compiling when it sees them. -
npm run lite
- runs the lite-server, a light-weight, static file server, written and maintained by
John Papa and
Christopher Martin
with excellent support for Angular apps that use routing. -
npm run typings
- runs the typings tool. -
npm run postinstall
- called by npm automatically after it successfully completes package installation. This script installs the TypeScript definition files this app requires.
Here are the test related scripts:
-
npm test
- compiles, runs and watches the karma unit tests -
npm webdriver:update
- ONE TIME update for protractor end-to-end (e2e) tests -
npm run e2e
- run protractor e2e tests, written in JavaScript (*e2e-spec.js)
Shut it down manually with Ctrl-C.
git clone 比较慢 npm install.png Paste_Image.png用npm安装出现问题,换用 cnpm 试试
cnpm install.png 安装ing 安装成功,WARN可以暂时忽略。。。使用 npm start
开始吧!
这时会自动启动浏览器,修改代码会自动刷新(真贴心),省去了配置 gup、grunt的麻烦。
默认界面至此,开发环境配置好了!Happy coding!
网友评论