0

I have this string :

this.badge = `<span class="badge">{{ notification}}</span>`

to interpret the {{ notification}} expression I do :

this.badge = this.$interpolate(this.badge)(this)

What i would like to do now is to add an ng-if in the span element :

this.badge = `<span ng-if="notification > 0"class="badge">{{ notification}}</span>`

But the $interpolate service does not support this, how can I "compile" the condition of ng-if ?

Mouad Ennaciri
  • 1,217
  • 3
  • 15
  • 28

1 Answers1

0

you can to use local scope:

this.badge = '<span ng-if="'+(scope.notification > 0)+'" class="badge">'+scope.notification+'</span>';
Dmitry Matrosov
  • 412
  • 4
  • 5