在多个数组上的ng-repeat中求和

时间:2017-09-07 04:26:21

标签: angularjs arrays

我希望在这种情况下显示每个用户的总和(cc1,cc2等)

HTML:

if(!is_array($input->request('roles')))
    $roles[] = $input->request('roles');

数据采用以下格式

<tr ng-repeat="month in months">                          
      <td>{{$index+1}}</td>  
      <td>{{month[0].cc_name}}</td>
      <td ng-repeat="points in month[0].cc_point">{{points.point}}</td>                                
</tr>

并且每条记录都包含

[
    {t_id: "8", fkcc_id: "5", fkagent_id: "1", fktype_id: "1", fkc_id: "1"},
    {t_id: "6", fkcc_id: "1", fkagent_id: "1", fktype_id: "1", fkc_id: "1"},
    {t_id: "7", fkcc_id: "1", fkagent_id: "1", fktype_id: "6", fkc_id: "1"}
]

2 个答案:

答案 0 :(得分:0)

<tr ng-repeat="month in months">
    <td>{{$index+1}}</td>
    <td>{{month.cc_name}}</td>
    <td ng-repeat="points in month.cc_point">{{points.point}}</td>
</tr>

答案 1 :(得分:0)

不幸的是没有捷径,你必须自己编码。

ggplot(data = perWorkField) + 
geom_point(mapping = aes(x = percent, y = module), shape = 20) + xlim(c(0, 100)) + 
geom_polygon(aes(x=c(0,25,25,0),
               y=c(0.5,0.5,4.5,4.5)),fill="#F5817A",color=NA) +
geom_polygon(aes(x=c(25,75,75,25),
               y=c(0.5,0.5,4.5,4.5)),fill="#FFFF0044",color=NA) +
geom_polygon(aes(x=c(75,100,100,75),
               y=c(0.5,0.5,4.5,4.5)),fill="#00FF0044",color=NA) + 
geom_point(mapping = aes(x = percent, y = module)) + theme_light()