Reputation: 9344
I have the below HTML code assigned to a variable which I inject this dynamically in another template. The *ngIf
returns false and I see in the source like *ngIf="false"
. How can I make this condition work?
html: `
<img src='./assets/images/icons-pests/bug.png' class="bug-icon"
*ngIf="${that.getPest(field.FieldID) > 0}"/> `
Note: The edit does not require for formatting the code as it will change my intention.
Upvotes: 0
Views: 63
Reputation: 13
From your second comment it seems that you wish to show one img on said condition and the other if not met? In which case:
<img src="......" *ngIf="that.getPest(field.FieldID) > 0 ?; else myOtherImage" />
<img #myOtherImage src="......" />
Upvotes: 1
Reputation: 9344
Just sorted out:
html: `
<img src='./assets/images/crops-png/${field.IconName.toLowerCase()}.png' class="crop-icon"/>
${that.getPest(field.FieldID) > 0 ?
'<img src=\'./assets/images/icons-pests/bug.png\' class="bug-icon">' : ''}
`
Upvotes: 0