所以我有以下ng-repeat
:
<th ng-repeat="field in tableFields" translate="{{field.headerTitle | translate}}"
ts-criteria="{{field.sortable ? field.fieldKey : null}}">
<label class="i-checks" ng-if="field.isCheckbox">
<input type="checkbox" ng-model="checkAll" ng-change="selectAll(checkAll)">
<i></i>
</label>
</th>
这工作正常,但由于外部脚本中存在一些错误,如果 field.fieldKey 为 null
,则不应设置 ts-criteria
。所以我的问题是如何完全删除该属性?
最佳答案
如果认为一个好的选择是使用 ng-switch
来选择是否应设置您的属性。
没有完整的代码,但它会是这样的:
<div ng-switch on="myVar">
<th ng-switch-when="true" ts-criteria>ts-criteria here</th>
<th ng-switch-default>not here</th>
</div>
通过更改 myVar
值来尝试。
关于javascript - ng-repeat 元素删除属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41464450/