Note09--Filter
程序员文章站
2022-03-29 14:26:49
1. 目录结构
2. e.g.
a. Filter.html
<...
1. 目录结构
2. e.g.
a. Filter.html
<html ng-app="MyModule"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <script src="framework/angular-1.3.0.14/angular.js"></script> <script src="Filter.js"></script> </head> <body> {{ 1304375948024 | date }} <br> {{ 1304375948024 | date:"MM/dd/yyyy @ h:mma" }} <br> {{ 1304375948024 | date:"yyyy-MM-dd hh:mm:ss" }} <br> </body> </html>
b. Filter.js
var myModule=angular.module("MyModule",[]);
3. 自定义Filter
a. e.g.
i. MyFilter.html
<html ng-app="MyModule"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <script src="framework/angular-1.3.0.14/angular.js"></script> <script src="MyFilter.js"></script> </head> <body> {{'大漠穷秋'|filter1 }} </body> </html>
ii. MyFilter.js
var myModule=angular.module("MyModule",[]); myModule.filter('filter1',function(){ return function(item){ return item + 'o(∩_∩)o'; } });
上一篇: 微信公众号别人都在猛赚你却一直在观望