价格统计的问题

来源:互联网 发布:国密算法介绍 编辑:程序博客网 时间:2024/04/19 09:34

1,价格统计:

把出取出列到数组里;

function get_result_of_bid(bid_person){
   var array=[]
   for(var i=0;i<bid_person.length;i++){
       array[i]=object[i]['jj']
   }
   return get_counts_of_the_elements_in_an_array(array);
}


统计数组里相同出价的人数:

 function get_counts_of_the_elements_in_an_array(array){
var count = _.groupBy(array);
var new_array= [];
for(key in count){
    new_array.push({jj':key,'number':count[key].length}) 
}
return new_array;
}

最后$scope.jj_counts=get_bid();

在haml里面:%li(style="height:50px" ng-repeat="jj_count in jj_counts")
        %span(style="float:left") ¥{{jj_count.jj}}
        %span(style="float:right") {{jj_count.number}}人

2.底部显示

haml:%footer
  %ul(class="footer-nav")
    %p(align="center" ng-show="footer_number")
      竞价结果:{{bid_winner.name}}   {{bid_winner.phone}}    ¥{{bid_winner.jj}}

ng-show="footer_number"是显示,ooter_number不是函数,用true或者false显示控制

原创粉丝点击