我的html文件中有一个条件,如果设备转为横向模式,它将自动需要显示已使用过滤器的那些字段中的一些字段但是当我运行程序时,我得到以下代码。
<tbody>
<tr ng-repeat="ledger in vm.ledgers | orderBy: vm.orderByField : vm.reverseSort" ng-click="vm.gotoLedgerDetail(ledger)">
<td>{{ ledger.date | formatDate}}</td>
<td ng-if="vm.orientation === 'landscape'">{{ ledger.transaction_type === "FarmerTrade" ? ledger.bill_no | billtext : ledger.description | isNullAdvance}}</td>
<td align="right">{{ ledger.amount_in | INR}}</td>
<td align="right">{{ ledger.amount_out | INR}}</td>
<td align="right">{{ ledger.other_amount | INR }}</td>
<td align="right">{{ ledger.balance | INR}}</td>
</tr>
</tbody>
错误是:
vendor.js:13424 Error: [$parse:syntax] Syntax Error: Token '|' is unexpected, expecting [:] at column 60 of the expression [ledger.transaction_type === "FarmerTrade" ? ledger.bill_no | billtext : ledger.description | isNullAdvance] starting at [| billtext : ledger.description | isNullAdvance].
过滤器是:
.filter('billtext', function () {
return function (data) {
return 'Bill-No' + ': ' + data.name;
};
})
答案 0 :(得分:1)
请尝试以下代码:
<tbody>
<tr ng-repeat="ledger in vm.ledgers | orderBy: vm.orderByField : vm.reverseSort" ng-click="vm.gotoLedgerDetail(ledger)">
<td>{{ ledger.date | formatDate}}</td>
<td ng-if="vm.orientation === 'landscape'">{{ ledger.transaction_type === "FarmerTrade" ? (ledger.bill_no | billtext) : (ledger.description | isNullAdvance)}}</td>
<td align="right">{{ ledger.amount_in | INR}}</td>
<td align="right">{{ ledger.amount_out | INR}}</td>
<td align="right">{{ ledger.other_amount | INR }}</td>
<td align="right">{{ ledger.balance | INR}}</td>
</tr>
</tbody>