Javascript 如何使用ng开关使if else在ng中重复工作?
或任何其他ng 在我上面的例子中,我有一个包含一些比特币交易的模型,一些是传入的,一些是传出的,两者都有一个不同的图标Javascript 如何使用ng开关使if else在ng中重复工作?,javascript,angularjs,angularjs-ng-repeat,ng-switch,Javascript,Angularjs,Angularjs Ng Repeat,Ng Switch,或任何其他ng 在我上面的例子中,我有一个包含一些比特币交易的模型,一些是传入的,一些是传出的,两者都有一个不同的图标 vm.transactions = [ { type: 'incoming', comment: 'Recieved from multiple addresses', time: '10 hours ago', amount: 0.00498623 }, { type: 'incoming', comment: 'R
vm.transactions = [
{
type: 'incoming',
comment: 'Recieved from multiple addresses',
time: '10 hours ago',
amount: 0.00498623
},
{
type: 'incoming',
comment: 'Recieve from 1MgZLyz6d8djEqe68XoPpsjx9BFQyVAtXN',
time: '12 hours ago',
amount: 0.003
},
{
type: 'outgoing',
comment: 'Sent to 17dPAMzZiosQYVty6ES4KSWN8R8XFcxShH',
time: 'Jan 15th 2015',
amount: 0.01
},
{
type: 'incoming',
comment: 'Recieved from multiple addresses',
time: 'Jan 14th 2015',
amount: 0.02874
},
{
type: 'outgoing',
comment: 'Sent to 1GS9E86Y3mhK7Qwm1vqvgCmpE5u6MMxPML',
time: 'Jan 12th 2015',
amount: 0.064904
}
];
我找到这些文件是关于
用法
...
...
...
这就是我目前正在尝试的,但是图标没有显示出来:
<tr class="row_body"
ng-repeat="trans in transactions">
<td class="td_icon" ng-switch="{{trans.type}}">
<div ng-switch-when="incoming" class="icon-download">↓</div>
<div ng-switch-when="outgoing" class="icon-upload">↑</div>
</td>
<td class="td_comment">
{{ trans.comment }}
<p class="date">{{ trans.time }}</p>
</td>
<td class="td_amount green">{{ trans.amount }}</td>
</tr>
↓
↑
{{trans.comment}}
{{trans.time}
{{trans.amount}}
你知道我哪里做错了吗?或者我需要使用另一个ng
吗?更改
<td class="td_icon" ng-switch="{{trans.type}}">
到
术语表达式
有时在文档中会令人混淆
您想删除此行的花括号(angular将为您评估
ng开关的值):
woot!:D kk。。。现在是时候看看我是否能在课堂上发挥作用了
<td class="td_icon" ng-switch="{{trans.type}}">
<td class="td_icon" ng-switch="trans.type">
<!-- before -->
<td class="td_icon" ng-switch="{{trans.type}}">
<!-- after -->
<td class="td_icon" ng-switch="trans.type">