https://github.com/lianbinghua

angular filter

日期格式化:

<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 112030”

两个参数的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

  

  

posted @ 2015-09-22 15:40  连冰华  阅读(192)  评论(0编辑  收藏  举报