Created
June 13, 2014 18:26
-
-
Save tario/1b6155b5c97e747abe32 to your computer and use it in GitHub Desktop.
controllers.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
/* Controllers */ | |
var phonecatApp = angular.module('phonecatApp', []); | |
var uppercaseAllAttributes = function(x) { | |
var ret = {}; | |
for (var k in x) { | |
var value = x[k]; | |
ret[k] = value.toUpperCase ? value.toUpperCase() : value; | |
}; | |
return ret; | |
}; | |
phonecatApp.filter('uppercaseAllThings', function() { | |
return function( items, enabled ) { | |
if (enabled) { | |
var newitems = []; | |
angular.forEach(items, function(item) { | |
newitems.push(uppercaseAllAttributes(item)); | |
}); | |
return newitems; | |
} | |
return items; | |
}; | |
}); | |
phonecatApp.controller('PhoneListCtrl', function($scope) { | |
$scope.phones = [ | |
{'name': 'Nexus S', | |
'snippet': 'Fast just got faster with Nexus S.', | |
'age': 1}, | |
{'name': 'Motorola XOOM™ with Wi-Fi', | |
'snippet': 'The Next, Next Generation tablet.', | |
'age': 2}, | |
{'name': 'MOTOROLA XOOM™', | |
'snippet': 'The Next, Next Generation tablet.', | |
'age': 3} | |
]; | |
$scope.orderProp = 'age'; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment