ng-repeat th 元素删除属性
ng-repeat th element remove attribute
所以我有以下 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 is 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
值 来尝试。
所以我有以下 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 is 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
值 来尝试。