0

I have certain tags for tracking events in analytics.

  <div class="video"
   analytics-event="{{track.event}}"
   analytics-category="{{track.category}}">
   ...
  </div>

The thing is that sometimes track.event (or track.category) is empty and I don't want that empty tag in there. <div class="video" analytics-event>...<div>

Is there a way to display them conditionally?

1
  • I still dont get what you want, if track.event is empty and track.category is not empty, do you want to display? <div class="video" analytics-category="xxx"> Commented Jun 28, 2017 at 11:20

1 Answer 1

1

Use ng-if

<div ng-if="track.event" class="video"
   analytics-event="{{track.event}}">
   ...
</div>    

if it does not present,

<div  ng-if="!track.event" class="video"
   analytics-event>
</div>
Sign up to request clarification or add additional context in comments.

5 Comments

Ok, ok, and what if I have two tags?
what do you mean by two tags?
just add a condition ng-if="track.event" && "track.category"
@JorgeAnzola did it help
Yes @Sajeetharan, indeed. Thanks. I think that is probably not the best solution, but for my short understanding of Angular, I think is fine.

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.