<!DOCTYPE html>
<html ng-app='test'>
<head>
<meta charset="utf-8">
<title>angular</title>
<meta name="viewport" content="width=device-width,initial-scale=1.0,
maximum-scale=1.0,minimum-scale=1.0,user-scalable=no">
<link rel="stylesheet" type="text/css" href="static/css/reset.css">
<script src="bower_components/angular/angular.js" charset="utf-8"></script>
<script >
var app=angular.module('test',[])
app.filter('kuaiji',function(){
return function(input,args){
alert(input+','+args)
if (input<0) {
return '('+(-input)+')'
}else {
return input
}
}
})
app.controller('zhangsan',function($scope,$http){
$scope.arr=[
{name:'买早餐',count:3,price:-8},
{name:'卖出字画',count:5,price:25},
{name:'请领导吃饭',count:2,price:-250}
]
})
</script>
</head>
<body ng-controller='zhangsan'>
<ul>
<li ng-repeat='v in arr'>{{v.name}} 数量:{{v.count}} 支出{{v.count*v.price |kuaiji:'55,yyyy-dd-MM'}}</li>
</ul>
</body>
</html>
网友评论