首页 > 代码库 > angular第四天
angular第四天
1、过滤器种类
1.1 limitTo
1.2 urrency
1.3 number
1.4 json
1.5 lowercase
1.6 uppercase
1.7 date
1.8 orderby
<!-- index.html --><!DOCTYPE html><html ng-app="myApp"><head> <meta charset="UTF-8"> <title>Document</title> <script src="http://www.mamicode.com/angular.js"></script></head><body> <div> <!-- 正排序:从小到大 --> <pre> {{ tring | orderBy: "age" | json}} </pre> <pre> {{ tring | orderBy: "name" | json}} </pre> <pre> {{ tring | orderBy: "sex" | json}} </pre> <!-- 逆排序:从到小 --> <pre> {{ tring | orderBy: "age" : true | json}} </pre> </div></body><script type="text/javascript"> var app = angular.module("myApp", []); app.run(["$rootScope",function($rootScope){ $rootScope.tring = [ { "name": "gaoxiong", "age": 23, "sex": "female" },{ "name": "xiaohua", "age": 22, "sex": "ddzx" },{ "name": "liuyingchun", "age": 21, "sex": "female" } ] }]); console.log(app);</script></html>
1.9 filter
<!-- index.html --><!DOCTYPE html><html ng-app="myApp"><head> <meta charset="UTF-8"> <title>Document</title> <script src="http://www.mamicode.com/angular.js"></script></head><body> <p>匹配包含</p> <div> {{ tring | filter: "x" }} </div> <p>匹配整体</p> <div> {{ tring | filter: "x" : true }} </div></body><script type="text/javascript"> var app = angular.module("myApp", []); app.run(["$rootScope",function($rootScope){ $rootScope.tring = [ { "name": "gaoxiong", "age": 23, "sex": "female" },{ "name": "xiaohua", "age": 22, "sex": "ddzx" },{ "name": "liuyingchun", "age": 21, "sex": "female" },{ "name": "x", "age": 20, "sex": "female" } ] }]); console.log(app);</script></html>
angular第四天
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。