Angular 过滤器的简单使用
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Filter</title> 6 7 <style> 8 [ng\:cloak],[ng-cloak],[data-ng-cloak],[x-ng-cloak],. 9 ng-cloak,.x-ng-cloak,.ng-hide:not(.ng-hide-animate) 10 { 11 display:none !important; 12 } 13 ng\:form{ 14 display:block; 15 } 16 .ng-animate-shim{ 17 visibility:hidden; 18 } 19 .ng-anchor{ 20 position:absolute; 21 } 22 </style> 23 24 </head> 25 <body ng-app="app" ng-controller="myCtrl" ng-cloak> 26 27 <p><span>{{1288323623006 | date:'yyyy-MM-dd HH:mm:ss Z'}}</span><br></p> 28 <p><span>{{'young' | myFilter}}</span><br></p> 29 30 <script src="bower_components/angular/angular.js"></script> 31 32 <script> 33 34 var app = angular.module("app",[]); 35 //自定义过滤器 36 app.filter("myFilter",function () { 37 return function (txt) { 38 return txt+"mine"; 39 } 40 }) 41 app.controller('myCtrl',["$scope",function ($scope) { 42 43 }]); 44 45 </script> 46 47 </body> 48 </html>