html:
<tr ng-repeat="obj in rankList track by $index" ng-click="pageToElecAnalysis(obj.id)">
<td><i class="circle-store"></i><span>{{obj.leaserName}}</span></td>
<td>{{$index+1}}</td>
<td>{{obj.totleTagNames}}</td>
<td width="15%" ng-bind-html="translateValue(obj.tate)"></td>
</tr>
js:
// 翻译同比:
$scope.translateValue = function (value) {
var temp = value;
var html = value;
value = value.substring(0, value.length - 1);
if ((value * 1) > 0) {
html = '<div class="percent"> <i class="allIcon-tslTen rise"></i> <p>' + temp + '</p></div>'
} else if ((value * 1) < 0) {
html = '<div class="percent"> <i class="allIcon-tslTen reduce"></i> <p>' + temp + '</p></div>'
}
return $sce.trustAsHtml(html);
}
- value = value.substring(0, value.length - 1); 指截取字符串 取从0开始到最后一个之前
- value * 1 表示把获取的内容转换成文字