@@ -13,23 +13,25 @@ details for any device.
1313<img class="diagram" src="img/tutorial/catalog_screen.png" width="488" height="413" alt="demo
1414application running in the browser">
1515
16- Work through the tutorial to see how Angular makes browsers smarter — without the use of native
17- extensions or plug-ins. As you work through the tutorial, you will :
16+ Follow the tutorial to see how Angular makes browsers smarter — without the use of native
17+ extensions or plug-ins:
1818
19- * See examples of how to use client-side data binding and dependency injection to build dynamic
20- views of data that change immediately in response to user actions.
21- * See how Angular creates listeners on your data without the need for DOM manipulation.
22- * Learn a better, easier way to test your web apps.
23- * Learn how to use Angular services to make common web tasks, such as getting data into your app,
24- easier.
19+ * See examples of how to use client-side data binding to build dynamic views of data that change
20+ immediately in response to user actions.
21+ * See how Angular keeps your views in synch with your data without the need for DOM manipulation.
22+ * Learn a better, easier way to test your web apps, with Karma and Protractor .
23+ * Learn how to use dependency injection and services to make common web tasks, such as getting data
24+ into your app, easier.
2525
2626When you finish the tutorial you will be able to:
2727
2828* Create a dynamic application that works in all modern browsers.
29- * Define the differences between Angular and common JavaScript frameworks.
30- * Understand how data binding works in AngularJS.
31- * Create and run unit tests.
32- * Create and run end to end tests.
29+ * Use data binding to wire up your data model to your views.
30+ * Create and run unit tests, with Karma.
31+ * Create and run end to end tests, with Protractor.
32+ * Move application logic out of the template and into Controllers.
33+ * Get data from a server using Angular services.
34+ * Apply animations to your application, using ngAnimate.
3335* Identify resources for learning more about AngularJS.
3436
3537The tutorial guides you through the entire process of building a simple application, including
@@ -40,31 +42,46 @@ You can go through the whole tutorial in a couple of hours or you may want to sp
4042really digging into it. If you're looking for a shorter introduction to AngularJS, check out the
4143{@link misc/started Getting Started} document.
4244
45+ # Get Started
4346
47+ The rest of this page explains how you can set up your machine to work with the code on your local
48+ machine. If you just want to read the tutorial then you can just go straight to the first step:
49+ [Step 0 - Bootstrapping](tutorial/step_00).
4450
4551# Working with the code
4652
47- You can follow along with this tutorial and hack on the code in either the Mac/Linux or the Windows
48- environment. The tutorial relies on the use of the [Git][git] versioning system for source code
49- management.
53+ You can follow along with this tutorial and hack on the code in the comfort of your own computer.
54+ In this way you can get hands-on practice of really writing AngularJS code and also on using the
55+ recommended testing tools.
56+
57+ The tutorial relies on the use of the [Git][git] versioning system for source code management.
58+ You don't need to know anything about Git to follow the tutorial other than how to install and run
59+ a few git commands.
5060
51- You don't need to know anything about Git to follow the tutorial. Select one of the tabs below
52- and follow the instructions for setting up your computer.
5361
62+ ### Install Git
5463
55- ## Install Git
64+ You can download and install Git from http://git-scm.com/download. Once installed you should have
65+ access to the `git` command line tool. The main commands that you will need to use are:
5666
57- You'll need Git, which you can get from [the Git site][git].
67+ - `git clone ...` : clone a remote repository onto your local machine
68+ - `git checkout ...` : check out a particular branch or a tagged version of the code to hack on
69+
70+ ### Download angular-phonecat
5871
5972Clone the [angular-phonecat repository][angular-phonecat] located at GitHub by running the following
6073command:
6174
6275```
63- git clone https://github.com/angular/angular-phonecat.git
76+ git clone --depth=14 https://github.com/angular/angular-phonecat.git
6477```
6578
6679This command creates the `angular-phonecat` directory in your current directory.
6780
81+ <div class="alert alert-info">The `--depth=14` option just tells Git to pull down only the last 14 commits. This makes the
82+ download much smaller and faster.
83+ </div>
84+
6885Change your current directory to `angular-phonecat`.
6986
7087```
@@ -75,118 +92,144 @@ The tutorial instructions, from now on, assume you are running all commands from
7592`angular-phonecat` directory.
7693
7794
78- ## Install Node.js
79-
80- If you want to run the built-in web-server and the test tools then you will also need
81- Node.js v0.10, or later.
95+ ### Install Node.js
8296
83- You can download Node.js from the [node.js website][node].
97+ If you want to run the preconfigured local web-server and the test tools then you will also need
98+ [Node.js v0.10+][node].
8499
100+ You can download a Node.js installer for your operating system from http://nodejs.org/download/.
85101
86- You can check the version of Node.js that you have installed by running the following command:
102+ Check the version of Node.js that you have installed by running the following command:
87103
88104```
89105node --version
90106```
91107
92- <div class="alert alert-info"><strong>Helpful note:<strong> If you need to run a different versions of node.js
108+ <div class="alert alert-info">If you need to run a different versions of node.js
93109 in your local environment, consider installing
94110 <a href="https://github.com/creationix/nvm" title="Node Version Manager Github Repo link">
95111 Node Version Manager (nvm)
96112 </a>.
97113</div>
98114
99- Once you have Node.js installed you can install the tool dependencies by running:
115+ Once you have Node.js installed on your machine you can download the tool dependencies by running:
100116
101117```
102118npm install
103119```
104120
105- This command will download the following tools, into the `node_modules` directive :
121+ This command will download the following tools, into the `node_modules` directory :
106122
107123- [Bower][bower] - client-side code package manager
108- - [http-server ][http-server] - simple local static web server
124+ - [Http-Server ][http-server] - simple local static web server
109125- [Karma][karma] - unit test runner
110- - [protractor ][protractor] - end 2 end test runner
126+ - [Protractor ][protractor] - end 2 end test runner
111127
112128Running `npm install` will also automatically run `bower install`, which will download the Angular
113129framework into the `bower_components` directory.
114130
115131The project is preconfigured with a number of npm helper scripts to make it easy to run the common
116- tasks that you will need while developing.
132+ tasks that you will need while developing:
133+
134+ - `npm start` : start a local development web-server
135+ - `npm test` : start the Karma unit test runner
136+ - `npm run protractor` : run the Protractor end 2 end tests
137+ - `npm update-webdriver` : install the drivers needed by Protractor
117138
118- ## Running Development Web Server
139+ ### Running Development Web Server
119140
120- The project is preconfigured to provide a simple static web server for hosting the application.
121- Start the web server by running:
141+ While Angular applications are purely client-side code, and it is possible to open them in a web
142+ browser directly from the file system, it is better to server them from a HTTP web server. In
143+ particular, for security reasons, most modern browsers will not allow JavaScript to make server
144+ requests if the page is loaded directly from the file system.
145+
146+ The angular-phonecat project is configured with a simple static web server for hosting the
147+ application during development. Start the web server by running:
122148
123149```
124150npm start
125151```
126152
127- Now you can browse to the application at:
153+ This will create a local webserver that is listening to port 8000 on your local machine.
154+ You can now browse to the application at:
128155
129156```
130157http://localhost:8000/app/index.html
131158```
132159
133- ## Running Unit Tests
160+ ### Running Unit Tests
161+
162+ We use unit tests to ensure that the JavaScript code in our application is operating correctly.
163+ Unit tests focus on testing small isolated parts of the application. The unit tests are kept in the
164+ `test/unit` directory.
134165
135- The project is preconfigured to use [Karma][karma] to run the unit tests for the application. Start
136- Karma by running:
166+ The angular-phonecat project is configured to use [Karma][karma] to run the unit tests for the
167+ application. Start Karma by running:
137168
138169```
139170npm test
140171```
141172
142- This will start the Karma unit test runner, open up a Chrome browser and execute all the unit tests
143- in this browser. Karma will then sit and watch all the source and test JavaScript files.
144- Whenever one of these files changes Karma re-runs all the unit tests.
173+ This will start the Karma unit test runner. Karma will read the configuration file at
174+ `test/karma.conf.js`. This configuration file tells Karma to:
145175
146- It is good to leave this running all the time as you will get immediate feedback from Karma as you
147- are working on the code.
176+ - open up a Chrome browser and connect it to Karma
177+ - execute all the unit tests in this browser
178+ - report the results of these tests in the terminal/command line window
179+ - watch all the project's JavaScript files and re-run the tests whenever any of these change
148180
181+ It is good to leave this running all the time, in the background, as it will give you immediate
182+ feedback about whether your changes pass the unit tests while you are working on the code.
149183
150- ## Running End to End Tests
151184
152- The project is preconfigured to use [Protractor][protractor] to run the end to end tests for the
153- application. Set up the binaries protractor needs to run by running:
185+ ### Running End to End Tests
154186
155- ```
156- npm run update-webdriver
157- ```
158- (You will only need to do this once) Execute the Protractor test scripts against your application
159- by running:
187+ We use End to End tests to ensure that the application as a whole operates as expected.
188+ End to End tests are designed to test the whole client side application, in particular that the
189+ views are displaying and behaving correctly. It does this by simulating real user interaction with
190+ the real application running in the browser.
191+
192+ The End to End tests are kept in the `test/e2e` directory.
193+
194+ The angular-phonecat project is configured to use [Protractor][protractor] to run the End to End
195+ tests for the application. Protractor relies upon a set of drivers to allow it to interact with
196+ the browser. You can install these drivers by running:
160197
161198```
162- npm run protractor
199+ npm run update-webdriver
163200```
164201
165- This will start the Protractor end to end test runner, open up a Chrome browser and execute all the
166- end to end test scripts in this browser. Once the test scripts finish, the browser will close down
167- and Protractor will exit.
202+ *(You should only need to do this once.)*
168203
169- It is good to run the end to end tests whenever you make changes to the HTML views or want to check
170- that the application as a whole is executing correctly.
204+ Since Protractor works by interacting with a running application, we need to start our web server:
171205
172- <div class="alert alert-info"><strong>Helpful note:</strong> Protractor requires that a web server is running
173- and serving up the application at the default URL: `http://localhost:8000/app/index.html`. You can
174- start the provided development server by running `npm start`.
175- </div>
206+ ```
207+ npm start
208+ ```
176209
210+ Then in a separate terminal/command line window, we can run the Protractor test scripts against the
211+ application by running:
177212
178- # Get Started
213+ ```
214+ npm run protractor
215+ ```
179216
180- Now your environment is ready, it is time to get started developing the Angular PhoneCat
181- application.
217+ Protractor will read the configuration file at `test/protractor-conf.js`. This configuration tells
218+ Protractor to:
182219
183- <a href="tutorial/step_00" title="Next Step"><span class="btn btn-primary">Step 0 - Bootstrapping</span></a>
220+ - open up a Chrome browser and connect it to the application
221+ - execute all the End to End tests in this browser
222+ - report the results of these tests in the terminal/command line window
223+ - close down the browser and exit
184224
225+ It is good to run the end to end tests whenever you make changes to the HTML views or want to check
226+ that the application as a whole is executing correctly. It is very common to run End to End tests
227+ before pushing a new commit of changes to a remote repository.
185228
186229
187- [git]: http://git-scm.com/download
188- [angular-phonecat]: https://github.com/angular/angular-phonecat
230+ [git]: http://git-scm.com/
189231[node]: http://nodejs.org/
232+ [angular-phonecat]: https://github.com/angular/angular-phonecat
190233[protractor]: https://github.com/angular/protractor
191234[bower]: http://bower.io/
192235[http-server]: https://github.com/nodeapps/http-server
0 commit comments