Created
April 25, 2014 23:44
-
-
Save carloscarcamo/11307079 to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"></script> | |
<meta name="description" content="[filters]" /> | |
<meta charset="utf-8"> | |
<title>Filters</title> | |
</head> | |
<body ng-app='HomeModule' ng-controller="HomeController"> | |
<h1>{{pageHeading | titleCase}}</h1> | |
</body> | |
</html> |
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
var homeModule = angular.module('HomeModule', []); | |
homeModule.filter('titleCase', function(){ | |
var titleCaseFilter = function(input){ | |
var words = input.split(' '); | |
for(var i=0; i<words.length; i++){ | |
words[i] = words[i].charAt(0).toUpperCase() + words[i].slice(1); | |
} | |
return words.join(' '); | |
}; | |
return titleCaseFilter; | |
}); | |
homeModule.controller('HomeController', ['$scope', function($scope){ | |
$scope.pageHeading = 'behold the majesty of your page title'; | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment