You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Copy file name to clipboardexpand all lines: docs/content/tutorial/step_01.ngdoc
+2-5
Original file line number
Diff line number
Diff line change
@@ -12,15 +12,12 @@ dynamically display the same result with any set of data.
12
12
13
13
In this step you will add some basic information about two cell phones to an HTML page.
14
14
15
+
- The page now contains a list with information about two phones.
15
16
16
17
<div doc-tutorial-reset="1"></div>
17
18
18
19
19
-
The page now contains a list with information about two phones.
20
-
21
-
The most important changes are listed below. You can see the full diff on [GitHub](https://github.com/angular/angular-phonecat/compare/step-0...step-1):
to decouple the code and to separate concerns. With that in mind, let's use a little Angular and
15
+
JavaScript to add model, view, and controller components to our app.
16
16
17
+
- The list of three phones is now generated dynamically from data
17
18
18
19
<div doc-tutorial-reset="2"></div>
19
20
20
21
21
-
The app now contains a list with three phones.
22
-
23
-
The most important changes are listed below. You can see the full diff on [GitHub](https://github.com/angular/angular-phonecat/compare/step-1...step-2):
24
-
25
-
26
22
## View and Template
27
23
28
24
In Angular, the __view__ is a projection of the model through the HTML __template__. This means that
Don't forget that we need to load up the `phonecatApp` module into the test so that the controller
181
-
is available to be injected.
174
+
* Before each test we tell Angular to load the `phonecatApp` module.
175
+
* We ask Angular to `inject` the `$controller` service into our test function
176
+
* We use `$controller` to create an instance of the `PhoneListCtrl`
177
+
* With this instance, we verify that the phones array property on the scope contains three records.
178
+
182
179
183
180
### Writing and Running Tests
181
+
184
182
Angular developers prefer the syntax of Jasmine's Behavior-driven Development (BDD) framework when
185
183
writing tests. Although Angular does not require you to use Jasmine, we wrote all of the tests in
186
-
this tutorial in Jasmine. You can learn about Jasmine on the [Jasmine home page](http://jasmine.github.io/) and at the [Jasmine docs](http://jasmine.github.io/).
187
-
188
-
The angular-seed project is pre-configured to run all unit tests using [Karma](http://karma-runner.github.io/). Ensure that the necessary karma plugins are installed.
189
-
You can do this by issuing `npm install` into your terminal.
184
+
this tutorial in Jasmine v1.3. You can learn about Jasmine on the [Jasmine home page][jasmine] and
185
+
at the [Jasmine docs][jasmine-docs].
190
186
187
+
The angular-seed project is pre-configured to run unit tests using [Karma][karma] but you will need
188
+
to ensure that Karma and its necessary plugins are installed. You can do this by running
189
+
`npm install`.
191
190
192
-
To run the test, do the following:
191
+
To run the tests, and then watch the files for changes: `npm test`.
193
192
194
-
1. In a _separate_ terminal window or tab, go to the `angular-phonecat` directory and run
195
-
`npm test` to start the Karma server (the config file necessary to start the server is
196
-
located at `./test/karma.conf.js`).
197
-
198
-
2. Karma will start a new instance of Chrome browser automatically. Just ignore it and let it run in
193
+
* Karma will start a new instance of Chrome browser automatically. Just ignore it and let it run in
199
194
the background. Karma will use this browser for test execution.
195
+
* You should see the following or similar output in the terminal:
200
196
201
-
3. You should see the following or similar output in the terminal:
202
-
203
-
info: Karma server started at http://localhost:9876/
204
-
info (launcher): Starting browser "Chrome"
205
-
info (Chrome 22.0): Connected on socket id tPUm9DXcLHtZTKbAEO-n
Copy file name to clipboardexpand all lines: docs/content/tutorial/step_05.ngdoc
+5-8
Original file line number
Diff line number
Diff line change
@@ -11,14 +11,11 @@ from our server using one of Angular's built-in {@link guide/services services}
11
11
ng.$http $http}. We will use Angular's {@link guide/di dependency
12
12
injection (DI)} to provide the service to the `PhoneListCtrl` controller.
13
13
14
+
* There are now a list of 20 phones, loaded from the server.
14
15
15
16
<div doc-tutorial-reset="5"></div>
16
17
17
18
18
-
You should now see a list of 20 phones.
19
-
20
-
The most important changes are listed below. You can see the full diff on [GitHub](https://github.com/angular/angular-phonecat/compare/step-4...step-5):
21
-
22
19
## Data
23
20
The `app/phones/phones.json` file in your project is a dataset that contains a larger list of phones
Copy file name to clipboardexpand all lines: docs/content/tutorial/step_06.ngdoc
+1-6
Original file line number
Diff line number
Diff line change
@@ -10,15 +10,10 @@ In this step, you will add thumbnail images for the phones in the phone list, an
10
10
now, will go nowhere. In subsequent steps you will use the links to display additional information
11
11
about the phones in the catalog.
12
12
13
+
* There are now links and images of the phones in the list.
13
14
14
15
<div doc-tutorial-reset="6"></div>
15
16
16
-
17
-
You should now see links and images of the phones in the list.
18
-
19
-
The most important changes are listed below. You can see the full diff on [GitHub](https://github.com/angular/angular-phonecat/compare/step-5...step-6):
20
-
21
-
22
17
## Data
23
18
24
19
Note that the `phones.json` file contains unique ids and image urls for each of the phones. The
Note that when you now navigate to `app/index.html`, you are redirected to `app/index.html#/phones`
17
-
and the same phone list appears in the browser. When you click on a phone link the stub of a phone
18
-
detail page is displayed.
43
+
The new dependency `"angular-route": "~1.2.15"` tells bower to install a version of the
44
+
angular-route component that is compatible with version 1.2.15. We must tell bower to download
45
+
and install this dependency.
19
46
47
+
If you have bower installed globally then you can run `bower install` but for this project we have
48
+
preconfigured npm to run bower install for us:
20
49
21
-
The most important changes are listed below. You can see the full diff on [GitHub](https://github.com/angular/angular-phonecat/compare/step-6...step-7).
50
+
```
51
+
npm install
52
+
```
22
53
23
54
24
55
## Multiple Views, Routing and Layout Template
@@ -34,12 +65,11 @@ template into what we call a "layout template". This is a template that is commo
34
65
our application. Other "partial templates" are then included into this layout template depending on
35
66
the current "route" — the view that is currently displayed to the user.
36
67
37
-
Application routes in Angular are declared via the
38
-
{@link ngRoute.$routeProvider $routeProvider}, which is the provider of the
39
-
{@link ngRoute.$route $route service}. This service makes it easy to wire together
40
-
controllers, view templates, and the current
41
-
URL location in the browser. Using this feature we can implement [deep linking](http://en.wikipedia.org/wiki/Deep_linking), which lets us utilize the browser's
42
-
history (back and forward navigation) and bookmarks.
68
+
Application routes in Angular are declared via the {@link ngRoute.$routeProvider $routeProvider},
69
+
which is the provider of the {@link ngRoute.$route $route service}. This service makes it easy to
70
+
wire together controllers, view templates, and the current URL location in the browser. Using this
71
+
feature we can implement [deep linking](http://en.wikipedia.org/wiki/Deep_linking), which lets us
72
+
utilize the browser's history (back and forward navigation) and bookmarks.
43
73
44
74
45
75
### A Note About DI, Injector and Providers
@@ -68,6 +98,94 @@ of configuring the injector. As opposed to AMD or require.js modules, Angular mo
68
98
solve the problem of script load ordering or lazy script fetching. These goals are totally independent and
69
99
both module systems can live side by side and fulfil their goals.
70
100
101
+
## Template
102
+
103
+
The `$route` service is usually used in conjunction with the {@link ngRoute.directive:ngView
104
+
ngView} directive. The role of the `ngView` directive is to include the view template for the current
105
+
route into the layout template. This makes it a perfect fit for our `index.html` template.
106
+
107
+
<div class="alert alert-info">
108
+
**Note:** Starting with AngularJS version 1.2, `ngRoute` is in its own module and must be loaded by
109
+
loading the additional `angular-route.js` file, which we download via Bower above.
Copy file name to clipboardexpand all lines: docs/content/tutorial/step_08.ngdoc
+6-9
Original file line number
Diff line number
Diff line change
@@ -9,17 +9,14 @@
9
9
In this step, you will implement the phone details view, which is displayed when a user clicks on a
10
10
phone in the phone list.
11
11
12
-
13
-
<div doc-tutorial-reset="8"></div>
14
-
15
-
16
-
Now when you click on a phone on the list, the phone details page with phone-specific information
12
+
* When you click on a phone on the list, the phone details page with phone-specific information
17
13
is displayed.
18
14
19
-
To implement the phone details view we will use {@link ng.$http $http} to fetch
20
-
our data, and we'll flesh out the `phone-detail.html` view template.
15
+
To implement the phone details view we used {@link ng.$http $http} to fetch our data, and we
16
+
fleshed out the `phone-detail.html` view template.
17
+
18
+
<div doc-tutorial-reset="8"></div>
21
19
22
-
The most important changes are listed below. You can see the full diff on [GitHub](https://github.com/angular/angular-phonecat/compare/step-7...step-8):
Copy file name to clipboardexpand all lines: docs/content/tutorial/step_09.ngdoc
+7-12
Original file line number
Diff line number
Diff line change
@@ -5,20 +5,13 @@
5
5
6
6
<ul doc-tutorial-nav="9"></ul>
7
7
8
-
9
8
In this step you will learn how to create your own custom display filter.
10
9
11
-
12
-
<div doc-tutorial-reset="9"></div>
13
-
14
-
15
-
Navigate to one of the detail pages.
16
-
17
-
In the previous step, the details page displayed either "true" or "false" to indicate whether
10
+
* In the previous step, the details page displayed either "true" or "false" to indicate whether
18
11
certain phone features were present or not. We have used a custom filter to convert those text
19
12
strings into glyphs: ✓ for "true", and ✘ for "false". Let's see what the filter code looks like.
20
13
21
-
The most important changes are listed below. You can see the full diff on [GitHub](https://github.com/angular/angular-phonecat/compare/step-8...step-9):
14
+
<div doc-tutorial-reset="9"></div>
22
15
23
16
24
17
## Custom Filter
@@ -118,7 +111,7 @@ access to the filter that we want to test. See {@link angular.mock.inject angul
118
111
119
112
You should now see the following output in the Karma tab:
Copy file name to clipboardexpand all lines: docs/content/tutorial/step_10.ngdoc
+2-7
Original file line number
Diff line number
Diff line change
@@ -8,16 +8,11 @@
8
8
9
9
In this step, you will add a clickable phone image swapper to the phone details page.
10
10
11
-
12
-
<div doc-tutorial-reset="10"></div>
13
-
14
-
15
-
The phone details view displays one large image of the current phone and several smaller thumbnail
11
+
* The phone details view displays one large image of the current phone and several smaller thumbnail
16
12
images. It would be great if we could replace the large image with any of the thumbnails just by
17
13
clicking on the desired thumbnail image. Let's have a look at how we can do this with Angular.
18
14
19
-
The most important changes are listed below. You can see the full diff on [GitHub](https://github.com/angular/angular-phonecat/compare/step-9...step-10):
The new dependency `"angular-resource": "~1.2.15"` tells bower to install a version of the
45
+
angular-resource component that is compatible with version 1.2.15. We must tell bower to download
46
+
and install this dependency.
14
47
15
-
The next improvement we will make to our app is to define a custom service that represents a [RESTful](http://en.wikipedia.org/wiki/Representational_State_Transfer) client. Using this client we
16
-
can make XHR requests for data in an easier way, without having to deal with the lower-level {@link
17
-
ng.$http $http} API, HTTP methods and URLs.
48
+
If you have bower installed globally then you can run `bower install` but for this project we have
49
+
preconfigured npm to run bower install for us:
18
50
19
-
The most important changes are listed below. You can see the full diff on [GitHub](https://github.com/angular/angular-phonecat/compare/step-10...step-11):
51
+
```
52
+
npm install
53
+
```
20
54
21
55
22
56
## Template
23
57
24
-
The custom service is defined in `app/js/services.js` so we need to include this file in our layout
25
-
template. Additionally, we also need to load the `angular-resource.js` file, which contains the
26
-
{@link api/ngResource ngResource} module and in it the {@link api/ngResource.$resource $resource}
27
-
service, that we'll soon use:
58
+
Our custom resource service will be defined in `app/js/services.js` so we need to include this file
59
+
in our layout template. Additionally, we also need to load the `angular-resource.js` file, which
60
+
contains the {@link api/ngResource ngResource} module:
0 commit comments