Bij*_*ina 1 javascript angularjs angularjs-directive
我可以使用“+”在 ng-bind 中连接两个值。然而,第二值取决于条件。
如何使用ng-if或ng-switch隐藏/显示该值。我尝试使用 ng-if 但它吃了 ng-bind (即插值根本不显示。也许ng-if具有更高的优先级,因为ng-bind的优先级为 0。例如
<a ng-bind="(document.name) + (vm.showifConditionTrue)"></a>
感谢您的任何建议。
尝试这个:
<a ng-bind="(document.name) + (vm.showifConditionTrue ? 'what to show if true' : 'what to show if false')"></a>
Run Code Online (Sandbox Code Playgroud)
如果你不想在 false 时显示任何内容,只需使用
<a ng-bind="(document.name) + (vm.showifConditionTrue ? 'what to show if true' : '')"></a>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2191 次 |
| 最近记录: |