Skip to content

Instantly share code, notes, and snippets.

@tario
Created June 13, 2014 18:26
Show Gist options
  • Save tario/1b6155b5c97e747abe32 to your computer and use it in GitHub Desktop.
Save tario/1b6155b5c97e747abe32 to your computer and use it in GitHub Desktop.
controllers.js
'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