S Ali
S Ali

Reputation: 27

span tag binding issues with angular interpolation

I'm trying to use span tag inside{{}}with condition

<label class="control-label label-floating">{{labelEnglish =='Name'?labelEnglish + '<span style="color:red">*</span>' : labelEnglish}} </label>

as you can see I want to check if labelEnglish equal to Name it should bind red star to it otherwise just print the value

I tried to use ng-if <span ng-if="labelEnglish == 'Name'" style="color:red">*</span> within span and this is what is got enter image description here

I assigned a labelEnglish value to Name to display it in Name input and owner to owner input and so on <name name="dName" labelEnglish="Name" labelArabic="الاسم" required CurrentLanguageRequired="true"></name> how can i chick labelEnglish vlaue in this case?

Upvotes: 1

Views: 618

Answers (1)

Maxim Shoustin
Maxim Shoustin

Reputation: 77904

You cannot add DOM by this way.

Use ng-if / ng-show

<label class="control-label label-floating">
   {{labelEnglish}}
   <span ng-if="labelEnglish == 'Name'" style="color:red">*</span>         
</label>

Demo

Upvotes: 1

Related Questions