javascript - 如何使用 Angular 编写嵌套条件?

标签 javascript angularjs

我在显示页面中有一个名为 Ordered 的列,它将订单号打印为:

<div class="col-sm-2 detail" ng-if="clTxn.ordered">
  <a ng-if="relTransaction.txnType == 'Order'" ng-repeat="relTransaction in clTxn.relTransactions" ui-sref="order({id: relTransaction.txnId })">{{'Ord#'}}</a>
  <div class="title">Ordered</div>
</div>

订单工作正常,现在我需要在 relTransaction.txnType == 'Purchase' 时添加相同的内容。 我是 Angular 新手,但我尝试将上述相同的订单与购买一起放置,但对我不起作用。

请注意,订单和购买都必须满足以下条件:

'ng-if' => 'clTxn.ordered'

请帮帮我。

最佳答案

<div class="col-sm-2 detail" ng-if="clTxn.ordered">
  <a ng-if="['Order', 'Purchase'].indexOf(relTransaction.txnType) != -1" ng-repeat="relTransaction in clTxn.relTransactions" ui-sref="order({id: relTransaction.txnId })">{{'Ord#'}}</a>
  <div class="title">Ordered</div>
</div>

关于javascript - 如何使用 Angular 编写嵌套条件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33670560/

相关文章:

angularjs - Angular 拆分组件的最佳实践

javascript - 带有参数(托管图像的 URL)的 Ng map 标记图标不起作用

javascript - 如何从未命名的 JSON 对象数组中获取数据

javascript - Angularjs ng-repeat 函数从 get 返回 html

javascript - Angular 2 页面大小

html - Angular/Breeze - 无法在 HTML 文本输入中输入小数点

javascript - 尝试在 Canvas 上绘制每个快速排序迭代

javascript - 为什么 Microsoft Skydrive 不下载多个文件,即使 MS 示例显示了它? (wl.下载)

javascript - 加载其他函数时,最小-最大过滤器不起作用

javascript - JS/Jquery,匹配未找到 PNG = 匹配 ('/gif|jpg|jpeg|png/' )