相关疑难解决方法(0)

有条件地应用ng-repeat过滤器

我有一个包含数字和值的文本混合的对象.numbers当它是一个数字(显然)时,我想将过滤器应用于对象的值.但是当它不是一个数字时,我会好起来只是吐出字符串.应用于| number值格式化数字,但将字符串值保留为空(毕竟,它们不是数字).

我猜它必须是一个自定义过滤器(我还需要制作).有没有办法在做HTML时只在HTML中做ng-repeat

<table>
      <tr ng-repeat="(metric, metricData) in data">
        <td>{{metric}}</td>
        <td>{{metricData | number}}</td>
      </tr>
</table>

$scope.data = { name:"this is the name", 
                score:48
                outcome:"as expected",
                attendance:820,
                total:212.34
              };
Run Code Online (Sandbox Code Playgroud)

filter angularjs angularjs-ng-repeat

9
推荐指数
1
解决办法
2万
查看次数

标签 统计

angularjs ×1

angularjs-ng-repeat ×1

filter ×1