0

So i have the following 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>

This works fine however due to some errors in an external script the ts-criteria should not be set if field.fieldKey is null. So my question is how can i remove the attribute completely?

Marc Rasmussen
  • 19,771
  • 79
  • 203
  • 364

1 Answers1

2

If think a good option would be to use ng-switch to choose if your attribute should be set, or not.

Don't have your full code, but it would be something like:

<div ng-switch on="myVar">
    <th ng-switch-when="true" ts-criteria>ts-criteria here</th>
    <th ng-switch-default>not here</th>
</div>

Here is a demo on JSFiddle

Try it by changing myVar value.

Mistalis
  • 17,793
  • 13
  • 73
  • 97