转自:https://www.cnblogs.com/best/tag/Angular/
1.
1 <!DOCTYPE html> 2 <html> 3 <meta charset="utf-8"> 4 <script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script> 5 6 <body> 7 8 <div ng-app="myApp" ng-controller="myCtrl"> 9 10 11 姓名: {{ msg | reverse }} 12 13 </div> 14 15 <script> 16 var app = angular.module('myApp', []); 17 app.controller('myCtrl', function($scope) { 18 $scope.msg = "Runoob"; 19 }); 20 app.filter('reverse', function() { //可以注入依赖 21 return function(text) { 22 return text.split("").reverse().join(""); 23 } 24 }); 25 </script> 26 27 </body> 28 </html>