我有以下问题。我希望能够在变量可用时更改我的部分视图,我该怎么做?我尝试了ng-switch
和ng-if
,但我遗漏了一些东西。以下是代码。
HTML
<div class="form-row">
<p class="total__price-p">Total: <strong ng-if="selectedPrice"
class="total__price">
[[selectedPrice | currency : currSign : 2]]</strong></p>
</div>
前面的示例假设我有另一个变量discounted
稍后会被初始化,我希望该变量替换当前我该怎么做?
更新:我设法交换了这样的值。
<div class="form-row">
<p ng-if="totalx == undefined" class="total__price-p">Total: <strong ng-if="selectedPrice && totalx == undefined" class="total__price">
[[selectedPrice | currency : currSign : 2]]</strong>
</p>
<p ng-if="totalx !== undefined" class="total__price-p">Total: <strong class="total__price">
[[totalx | currency : currSign : 2]]</strong>
</p>
</div>
但是当我改变时,selectedPrice
discounted
应该适用于新价格。