2

Here is code pen demo

Want to hide below element if x.phone2 is null.

<div class="telePhone"  ><strong>Phone2 :</strong> {{x.phone2}}</div>

3 Answers 3

1

You can use ng-if for that (docs):

<div class="telePhone"  ng-if="x.phone2"><strong>Phone2 :</strong> {{x.phone2}}</div>

Updated code pen.

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

Comments

0
<div class="telePhone" 
     ng-if="x.phone2">
  <strong>Phone2 :</strong> {{x.phone2}}
</div>

Comments

0

If want to hide it and don't need two way binding use:

<div class="telePhone" ng-if="x.phone"><strong>Phone2 :</strong> {{x.phone2}}</div>

If you still need two way binding use:

<div class="telePhone" ng-show="x.phone"><strong>Phone2 :</strong> {{x.phone2}}</div>

Using ng-if will lower you overhead, but if you need to show the div if the x.phone value changes, you need to use ng-show.

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.