1、$filter
2、自定义过滤器
<!-- index.html --> <!DOCTYPE html> <html ng-app="myApp"> <head> <meta charset="UTF-8"> <title>Document</title> <script src="angular.js"></script> </head> <body> <div ng-controller="firstController"> <p>{{ name }}</p> <p>{{ num }}</p> </div> </body> <script type="text/javascript"> var app = angular.module("myApp", []); app.controller('firstController', ['$scope','$filter', function($scope, $filter){ $scope.num = 344342342357.32342565; $scope.name = $filter("firstUpper")("hello"); }]); //自定义过滤器的写法是返回一个函数 app.filter("firstUpper",function(){ //这里的参数就是使用过滤器的时候传入的参数 return function(str,num,nu2){ // console.log(str); // console.log(num); // console.log(nu2); return str.charAt(0).toUpperCase()+str.substring(1); } }) </script> </html>