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

Commit

Permalink
step-9 checkmark filter
Browse files Browse the repository at this point in the history
- Added custom checkmark filter
- Update phone detail template to use checkmark filter
- Added spec for the filter
  • Loading branch information
IgorMinar authored and petebacondarwin committed Dec 22, 2014
1 parent 8564fb4 commit 4147d18
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
1 change: 1 addition & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>
<script src="js/filters.js"></script>
</head>
<body>

Expand Down
3 changes: 2 additions & 1 deletion app/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

var phonecatApp = angular.module('phonecatApp', [
'ngRoute',
'phonecatControllers'
'phonecatControllers',
'phonecatFilters'
]);

phonecatApp.config(['$routeProvider',
Expand Down
6 changes: 6 additions & 0 deletions app/js/filters.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
'use strict';

/* Filters */

angular.module('phonecatFilters', []).filter('checkmark', function() {
return function(input) {
return input ? '\u2713' : '\u2718';
};
});
10 changes: 5 additions & 5 deletions app/partials/phone-detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ <h1>{{phone.name}}</h1>
<dt>Bluetooth</dt>
<dd>{{phone.connectivity.bluetooth}}</dd>
<dt>Infrared</dt>
<dd>{{phone.connectivity.infrared}}</dd>
<dd>{{phone.connectivity.infrared | checkmark}}</dd>
<dt>GPS</dt>
<dd>{{phone.connectivity.gps}}</dd>
<dd>{{phone.connectivity.gps | checkmark}}</dd>
</dl>
</li>
<li>
Expand Down Expand Up @@ -79,7 +79,7 @@ <h1>{{phone.name}}</h1>
<dt>Screen resolution</dt>
<dd>{{phone.display.screenResolution}}</dd>
<dt>Touch screen</dt>
<dd>{{phone.display.touchScreen}}</dd>
<dd>{{phone.display.touchScreen | checkmark}}</dd>
</dl>
</li>
<li>
Expand All @@ -92,9 +92,9 @@ <h1>{{phone.name}}</h1>
<dt>Audio / headphone jack</dt>
<dd>{{phone.hardware.audioJack}}</dd>
<dt>FM Radio</dt>
<dd>{{phone.hardware.fmRadio}}</dd>
<dd>{{phone.hardware.fmRadio | checkmark}}</dd>
<dt>Accelerometer</dt>
<dd>{{phone.hardware.accelerometer}}</dd>
<dd>{{phone.hardware.accelerometer | checkmark}}</dd>
</dl>
</li>
<li>
Expand Down
11 changes: 11 additions & 0 deletions test/unit/filtersSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,15 @@

describe('filter', function() {

beforeEach(module('phonecatFilters'));


describe('checkmark', function() {

it('should convert boolean values to unicode checkmark or cross',
inject(function(checkmarkFilter) {
expect(checkmarkFilter(true)).toBe('\u2713');
expect(checkmarkFilter(false)).toBe('\u2718');
}));
});
});

0 comments on commit 4147d18

Please sign in to comment.