Angular 学习笔记——filter
<!DOCTYPE html> <html lang="en" ng-app="myApp"> <head> <meta charset="UTF-8"> <title>Document</title> <script type="text/javascript" src="js/angular-1.3.0.js"></script> <script> var m1 = angular.module('myApp',[]); m1.filter('firstUpper',function(){ return function (str){ return str.charAt(0).toUpperCase() + str.substring(1); } }) m1.controller('may',['$scope','$filter',function($scope,$filter){ $scope.name = $filter('firstUpper')('hello'); }]) </script> </head> <body ng-controller='may'> <p>{{name }}</p> </body> </html>