angular 过滤器
来源:互联网 发布:tv霸网络电视直播 编辑:程序博客网 时间:2024/05/22 02:10
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>AngularJS</title>
<script type="text/javascript" src="angular.js" ></script>
<script>
//获取系统时间对象
var date = new Date();
var app = angular.module('myapp', []);
app.controller('myctrl', function($scope) {
//货币过滤器
$scope.money = 1000;
//大写过滤器
$scope.hello = "hello";
//小写过滤器
$scope.HELLOW = "HELLOW";
//日期过滤器
$scope.date = date;
//反转字符串
$scope.fzzfc = "abcde";
//长度过滤器
$scope.user = ["zs","ls","ls","ww"];
//子元素过滤器
$scope.users = [{
name:"zs",
age:20
},{
name:"ls",
age:21
},{
name:"ww",
age:22
}];
//默认排序
$scope.student = [{
id:1,
name:"张三",
age:20
},{
id:3,
name:"王五",
age:23
},{
id:2,
name:"李四",
age:22
}];
$scope.order = function(text){
console.log(text);
return text["id","-name"];
}
});
//反转字符串
app.filter('reverse', function() { //可以注入依赖
return function(text) {
return text.split("").reverse().join("");
}
});
</script>
</head>
<body style="padding: 20px" ng-app="myapp" ng-controller="myctrl">
<p>货币过滤器 : {{ money | currency}}</p>
<p>大写过滤器:{{hello | uppercase}}</p>
<p>小写过滤器:{{HELLOW | lowercase}}</p>
<p>日期过滤器:{{date | date:"yyyy.MM.dd HH:mm:ss"}}</p>
<p>反转字符串:{{fzzfc | reverse}}</p>
<!--保留的长度-->
<p>长度过滤器:{{user | limitTo:1}}</p>
<!--保留是条件-->
<p>子元素过滤器:{{users | filter:{'name':'ls','age':21} }}</p>
<hr />
<p>默认排序:{{student | orderBy}}</p>
<p>角标升序:{{student | orderBy:"+"}}</p>
<p>角标降序:{{student | orderBy:"-"}}</p>
<p>角标升序:{{student | orderBy:true}}</p>
<p>ID升序:{{student | orderBy:"id"}}</p>
<p>ID降序:{{student | orderBy:"-id"}}</p>
<p>ID升序name升序:{{student | orderBy:["id","name"]}}</p>
<p>ID升序name将序:{{student | orderBy:["id","-name"]}}</p>
<p>ID升序name将序:{{student | orderBy:order}}</p>
</body>
</html>
阅读全文
0 0
- angular过滤器
- angular过滤器
- Angular过滤器
- Angular过滤器
- angular过滤器
- Angular过滤器
- angular过滤器
- angular 过滤器
- angular过滤器
- Angular过滤器
- angular过滤器
- angular过滤器、自定义过滤器
- angular自定义过滤器
- angular过滤器二
- angular过滤器三
- angular js过滤器
- Angular之解读过滤器
- angular 常用过滤器
- vim使用小结
- spring boot学习(一)---建项目结构
- ThinkPHP网页打开的时候显示错误位置
- adb remount 系统提示只读文件系统Read-only file system,解决用adb disable-verity
- LeetCode 48 Rotate Image
- angular 过滤器
- Redis 讲解系列之 Redis的主从复制(一)
- apache和tomcat无法启动,调试小技巧
- Android App 改变状态栏颜色
- 木乃伊迷宫(存在一些bug,后面有改过的)
- 基于ionic2 的移动app开发过程《3》
- 怎么在eclipse中找回丢失的R.iava
- 自适应非极大值抑制算法
- Android自定义view浅谈(一)setContentView