Skip to content
This repository was archived by the owner on Nov 27, 2025. It is now read-only.

Commit 3fc729c

Browse files
committed
step-3 interactive search
- Added a search box to demonstrate how: - the data-binding works on input fields - to use [filter] filter - [ngRepeat] automatically shrinks and grows the number of phones in the view - Added an end-to-end test to: - show how end-to-end tests are written and used - to prove that the search box and the repeater are correctly wired together
1 parent d90cbe4 commit 3fc729c

File tree

2 files changed

+38
-7
lines changed

2 files changed

+38
-7
lines changed

app/index.html

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,27 @@
1010
</head>
1111
<body ng-controller="PhoneListCtrl">
1212

13-
<ul>
14-
<li ng-repeat="phone in phones">
15-
{{phone.name}}
16-
<p>{{phone.snippet}}</p>
17-
</li>
18-
</ul>
13+
<div class="container-fluid">
14+
<div class="row-fluid">
15+
<div class="span2">
16+
<!--Sidebar content-->
17+
18+
Search: <input ng-model="query">
19+
20+
</div>
21+
<div class="span10">
22+
<!--Body content-->
23+
24+
<ul class="phones">
25+
<li ng-repeat="phone in phones | filter:query">
26+
{{phone.name}}
27+
<p>{{phone.snippet}}</p>
28+
</li>
29+
</ul>
30+
31+
</div>
32+
</div>
33+
</div>
1934

2035
</body>
2136
</html>

test/e2e/scenarios.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,23 @@
22

33
/* http://docs.angularjs.org/guide/dev_guide.e2e-testing */
44

5-
describe('my app', function() {
5+
describe('PhoneCat App', function() {
66

7+
describe('Phone list view', function() {
78

9+
beforeEach(function() {
10+
browser().navigateTo('../../app/index.html');
11+
});
12+
13+
14+
it('should filter the phone list as user types into the search box', function() {
15+
expect(repeater('.phones li').count()).toBe(3);
16+
17+
input('query').enter('nexus');
18+
expect(repeater('.phones li').count()).toBe(1);
19+
20+
input('query').enter('motorola');
21+
expect(repeater('.phones li').count()).toBe(2);
22+
});
23+
});
824
});

0 commit comments

Comments
 (0)