Bas Bas - 1 month ago 9
TypeScript Question

Tyescript/Anular 2 doesn't display html into a ternary

The following will display it as text (with<\i class.. backslash and whitout ) and not as html, probably very simple, but i can't find it :(

<div *ngFor="let facility of facilities;">
{{facility['freewifi'] || facility['paidwifi'] ? '<\i class="fa fa-wifi fa-fw" aria-hidden="true"><\/i> :' : '' }}
</div>


Answer:

<i *ngIf="facility['freewifi'] || facility['paidwifi']" class="fa fa-wifi fa-fw" aria-hidden="true"></i>

Answer

Use *ngIf instead:

<i *ngIf="facility['freewifi'] || facility['paidwifi']" class="fa fa-wifi fa-fw" aria-hidden="true"></i>