Reputation: 337
In my .css file I have multiple classes representing my webpage's icon. Based on what I retrieve from my code I want to change the icon.
<ng-container *ngFor="let item of parameterStruct">
<span class="m-menu__link-wrap">
<i class="sidebar-icon HERE"></i>
<span class="m-menu__link-text icon-padding sideBar-text"
style="padding-left: 15px; font-size: 12px">
{{ item.description |translate }}
</span>
</span>
</ng-container>
Where I wrote HERE (in the i element) I want to insert my .css class that is item.description + '-icon'
(E.g. 'myClass-icon').
How can I do that?
Upvotes: 0
Views: 54
Reputation: 10975
To achieve expected result, use below option of using ngClass
<i class="sidebar-icon" [ngClass]="item.description?item.description + '-icon': ''"></i>
Upvotes: 0