0

For some condition, I would like replace a String in my model when displaying it in html. I could do this my modifying my model, but is there a more idiomatic option? Possibly this should be done with a filter?

  <tr ng-repeat="i in ctrl.data" >
      <td>
         <div ng-show="i.category == 'default'">
             none
         </div>
         <div ng-show="i.category != 'default'">
            {{ i.category }}
         </div>
      </td>
  </tr>

1 Answer 1

2
{{ i.category == 'default' ? 'none' : i.category }}

Or, if you have that in several places, use a filter.

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.