在AngularJs响应设定值视 [英] Setting value depending on response in AngularJs
本文介绍了在AngularJs响应设定值视的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
比方说,我有以下的code:
Let's say I have the following code:
<tr ng-repeat="transaction in $data">
<td data-title="'Id'" sortable="id">{{transaction.id}}</td>
<td data-title="'Player'" sortable="playerId">{{transaction.playerId}}</td>
<td data-title="'Type'" sortable="type">{{transaction.type}}</td>
<td data-title="'Date'" sortable="date">{{transaction.date | amDateFormat:'lll'}}</td>
<td data-title="'Provider'" sortable="provider">{{transaction.paymentMethod}}</td>
<td data-title="'Amount'" sortable="amount">{{transaction.amount | currency:'€ '}}</td>
<td data-title="'Code'" sortable="code">{{transaction.code}}</td>
<td data-title="'Status'" sortable="status">{{transaction.status}}</td>
</tr>
有关交易。code从服务器响应为SRV_DPS。我如何显示在浏览器的存款?
For "transaction.code" the response from the server is 'SRV_DPS'. How do I display that as "Deposit" in the browser?
推荐答案
使用自定义过滤器:
JS
.filter('convertCode', function() {
return function(code) {
return (code === 'SRV_DPS') ? 'Deposit' : code;
}
})
查看
{{transaction.code | convertCode}}
这篇关于在AngularJs响应设定值视的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文