Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 31cf6ff

Browse files
committed
step-5 Filtering Repeaters
- Add a search box to demonstrate: - How the data-binding works on input fields. - How to use the `filter` filter. - How `ngRepeat` automatically shrinks and grows the number of phones in the view. - Add an end-to-end test to: - Show how end-to-end tests are written and used. - Prove that the search box and the repeater are correctly wired together.
1 parent b971a31 commit 31cf6ff

File tree

2 files changed

+42
-9
lines changed

2 files changed

+42
-9
lines changed
+21-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
1-
<ul>
2-
<li ng-repeat="phone in $ctrl.phones">
3-
<span>{{phone.name}}</span>
4-
<p>{{phone.snippet}}</p>
5-
</li>
6-
</ul>
1+
<div class="container-fluid">
2+
<div class="row">
3+
<div class="col-md-2">
4+
<!--Sidebar content-->
5+
6+
Search: <input ng-model="$ctrl.query" />
7+
8+
</div>
9+
<div class="col-md-10">
10+
<!--Body content-->
11+
12+
<ul class="phones">
13+
<li ng-repeat="phone in $ctrl.phones | filter:$ctrl.query">
14+
<span>{{phone.name}}</span>
15+
<p>{{phone.snippet}}</p>
16+
</li>
17+
</ul>
18+
19+
</div>
20+
</div>
21+
</div>

e2e-tests/scenarios.js

+21-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,28 @@
33
// Angular E2E Testing Guide:
44
// https://docs.angularjs.org/guide/e2e-testing
55

6-
describe('My app', function() {
6+
describe('PhoneCat Application', function() {
7+
8+
describe('phoneList', function() {
9+
10+
beforeEach(function() {
11+
browser.get('index.html');
12+
});
13+
14+
it('should filter the phone list as a user types into the search box', function() {
15+
var phoneList = element.all(by.repeater('phone in $ctrl.phones'));
16+
var query = element(by.model('$ctrl.query'));
17+
18+
expect(phoneList.count()).toBe(3);
19+
20+
query.sendKeys('nexus');
21+
expect(phoneList.count()).toBe(1);
22+
23+
query.clear();
24+
query.sendKeys('motorola');
25+
expect(phoneList.count()).toBe(2);
26+
});
727

8-
beforeEach(function() {
9-
browser.get('index.html');
1028
});
1129

1230
});

0 commit comments

Comments
 (0)