簡體   English   中英

ng-repeat元素的remove屬性

[英]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>

這是有關JSFiddle的演示

通過更改myVar值進行嘗試

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM