Skip to content

Commit 471d0f6

Browse files
IgorMinarpetebacondarwin
authored andcommitted
step-9 checkmark filter
- Added custom checkmark filter - Update phone detail template to use checkmark filter - Added spec for the filter
1 parent 561d13b commit 471d0f6

File tree

5 files changed

+25
-6
lines changed

5 files changed

+25
-6
lines changed

app/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<script src="bower_components/angular-route/angular-route.js"></script>
1010
<script src="js/app.js"></script>
1111
<script src="js/controllers.js"></script>
12+
<script src="js/filters.js"></script>
1213
</head>
1314
<body>
1415

app/js/app.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
var phonecatApp = angular.module('phonecatApp', [
66
'ngRoute',
7-
'phonecatControllers'
7+
'phonecatControllers',
8+
'phonecatFilters'
89
]);
910

1011
phonecatApp.config(['$routeProvider',

app/js/filters.js

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
'use strict';
22

33
/* Filters */
4+
5+
angular.module('phonecatFilters', []).filter('checkmark', function() {
6+
return function(input) {
7+
return input ? '\u2713' : '\u2718';
8+
};
9+
});

app/partials/phone-detail.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ <h1>{{phone.name}}</h1>
4848
<dt>Bluetooth</dt>
4949
<dd>{{phone.connectivity.bluetooth}}</dd>
5050
<dt>Infrared</dt>
51-
<dd>{{phone.connectivity.infrared}}</dd>
51+
<dd>{{phone.connectivity.infrared | checkmark}}</dd>
5252
<dt>GPS</dt>
53-
<dd>{{phone.connectivity.gps}}</dd>
53+
<dd>{{phone.connectivity.gps | checkmark}}</dd>
5454
</dl>
5555
</li>
5656
<li>
@@ -79,7 +79,7 @@ <h1>{{phone.name}}</h1>
7979
<dt>Screen resolution</dt>
8080
<dd>{{phone.display.screenResolution}}</dd>
8181
<dt>Touch screen</dt>
82-
<dd>{{phone.display.touchScreen}}</dd>
82+
<dd>{{phone.display.touchScreen | checkmark}}</dd>
8383
</dl>
8484
</li>
8585
<li>
@@ -92,9 +92,9 @@ <h1>{{phone.name}}</h1>
9292
<dt>Audio / headphone jack</dt>
9393
<dd>{{phone.hardware.audioJack}}</dd>
9494
<dt>FM Radio</dt>
95-
<dd>{{phone.hardware.fmRadio}}</dd>
95+
<dd>{{phone.hardware.fmRadio | checkmark}}</dd>
9696
<dt>Accelerometer</dt>
97-
<dd>{{phone.hardware.accelerometer}}</dd>
97+
<dd>{{phone.hardware.accelerometer | checkmark}}</dd>
9898
</dl>
9999
</li>
100100
<li>

test/unit/filtersSpec.js

+11
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,15 @@
44

55
describe('filter', function() {
66

7+
beforeEach(module('phonecatFilters'));
8+
9+
10+
describe('checkmark', function() {
11+
12+
it('should convert boolean values to unicode checkmark or cross',
13+
inject(function(checkmarkFilter) {
14+
expect(checkmarkFilter(true)).toBe('\u2713');
15+
expect(checkmarkFilter(false)).toBe('\u2718');
16+
}));
17+
});
718
});

0 commit comments

Comments
 (0)