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?

3
  • please post your ts-criteria code Commented Jan 4, 2017 at 13:14
  • @SantoshShinde ts-criteria is from an external lib. github.com/mattiash/angular-tablesort Commented Jan 4, 2017 at 13:16
  • use switch case or conditional statement Commented Jan 4, 2017 at 13:25

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.