您的位置:首页 > Web前端 > AngularJS

angular filter

2015-09-22 15:40 597 查看
日期格式化:

<span ng-bind="topShowList.sendTime|dateFormat|date:'MM-dd HH:mm'"></span>

deliciousApp.filter("dateFormat",[function(){
return function(time){
return new Date(Date.parse(time.replace(/-/g,  "/")));
}
}]);

注意:topShowList.sendTime是string类型的日期,
例如“2015-08-09 11:20:30”


两个参数的filter:

<span ng-bind="voucherList.voucherLot.isFreeShip | limitOption:voucherList.voucherLot.orderMoney"></span>

app.filter("limitOption",function(){
return function(isFreeShip,orderMoney){
if(isFreeShip==1 && orderMoney>0){
return "包邮,订单满"+orderMoney+"元可用";
}else if(isFreeShip==1 && orderMoney==0){
return "包邮";
}else if(isFreeShip==0 && orderMoney==0){
return "无限制";
}else if(isFreeShip==0 && orderMoney>0){
return "订单满"+orderMoney+"元可用";
}
}
});


  

  

<em class="price" ng-bind="goodsList.skuInfo.isPromotion !='0' ?goodsList.skuInfo.promotionPrice:goodsList.skuInfo.theOriginalPrice | currency : '¥' "></em>
结果:¥16.8


  

  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: