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

Commit 12d7eb4

Browse files
petebacondarwingkalpak
authored andcommitted
step-8 Templating Links & Images
- Add a phone image and links to phone pages. - Add an end-to-end test that verifies the phone links. - Tweak the CSS to style the page just a notch.
1 parent 1e9f747 commit 12d7eb4

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

app/app.css

+17
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,20 @@ body {
22
padding-top: 20px;
33
}
44

5+
.phones {
6+
list-style: none;
7+
}
8+
9+
.phones li {
10+
clear: both;
11+
height: 115px;
12+
padding-top: 15px;
13+
}
14+
15+
.thumb {
16+
float: left;
17+
height: 100px;
18+
margin: -0.5em 1em 1.5em 0;
19+
padding-bottom: 1em;
20+
width: 100px;
21+
}

app/phone-list/phone-list.component.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ angular.
55
module('phoneList').
66
component('phoneList', {
77
templateUrl: 'phone-list/phone-list.template.html',
8-
controller: function PhoneListController($http) {
8+
controller: ['$http', function PhoneListController($http) {
99
var self = this;
1010
self.orderProp = 'age';
1111

1212
$http.get('phones/phones.json').then(function(response) {
1313
self.phones = response.data;
1414
});
15-
}
15+
}]
1616
});

app/phone-list/phone-list.template.html

+5-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@
2121
<!--Body content-->
2222

2323
<ul class="phones">
24-
<li ng-repeat="phone in $ctrl.phones | filter:$ctrl.query | orderBy:$ctrl.orderProp">
25-
<span>{{phone.name}}</span>
24+
<li ng-repeat="phone in $ctrl.phones | filter:$ctrl.query | orderBy:$ctrl.orderProp" class="thumbnail">
25+
<a href="#/phones/{{phone.id}}" class="thumb">
26+
<img ng-src="{{phone.imageUrl}}" alt="{{phone.name}}" />
27+
</a>
28+
<a href="#/phones/{{phone.id}}">{{phone.name}}</a>
2629
<p>{{phone.snippet}}</p>
2730
</li>
2831
</ul>

e2e-tests/scenarios.js

+8
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ describe('PhoneCat Application', function() {
5252
]);
5353
});
5454

55+
it('should render phone specific links', function() {
56+
var query = element(by.model('$ctrl.query'));
57+
query.sendKeys('nexus');
58+
59+
element.all(by.css('.phones li a')).first().click();
60+
expect(browser.getLocationAbsUrl()).toBe('/phones/nexus-s');
61+
});
62+
5563
});
5664

5765
});

0 commit comments

Comments
 (0)