Created
June 9, 2017 18:08
-
-
Save dileeph/6a61067ac2babaf2d7c44ea160487366 to your computer and use it in GitHub Desktop.
angular-filters.html
This file contains hidden or 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
| <html> | |
| <head> | |
| <script src="angular-1.4.8.js"></script> | |
| </head> | |
| <body ng-app="myapp"> | |
| <div ng-controller="aController"> | |
| {{ aValue | date}} <br/> | |
| {{bValue | uppercase}} | |
| <br/> | |
| <span ng-repeat="student in students | orderBy:'id'">{{student.id}} : {{student.name | capitalizeFirstChar}}</span> | |
| </div> | |
| <script> | |
| angular.module("myapp", []).controller("aController", function($scope){ | |
| $scope.aValue = 200; | |
| $scope.bValue = "myname"; | |
| $scope.students = [{"id":"23", "name":"john"}, {"id":"22", "name":"jane"}, {"id":"19", "name":"tom"}, {"id":"25", "name":"matt"}]; | |
| }); | |
| myapp.filter("capitalizeFirstChar", function(){ | |
| return function(x){ | |
| var i =0, y,c =""; | |
| for(i =0; i< x.length; i++){ | |
| if(i==0){ | |
| y = x[i].toUpperCase(); | |
| }else{ | |
| y = x[i]; | |
| } | |
| c +=y; | |
| } | |
| return c; | |
| } | |
| }) | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment