Skip to content

Instantly share code, notes, and snippets.

@carloscarcamo
Created April 25, 2014 23:44
Show Gist options
  • Save carloscarcamo/11307079 to your computer and use it in GitHub Desktop.
Save carloscarcamo/11307079 to your computer and use it in GitHub Desktop.
<!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>
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