If you are not going to change these classes dynamically, then using ngClass
is redundant. You can simply use class="fa fa-star"
in your template.
ngClass
should be used when you want to dynamically turn them on and off. There is an example in the docs:
Your component will have a method:
setClasses() { return { saveable: this.canSave, // true modified: !this.isUnchanged, // false special: this.isSpecial, // true } }
then use ngClass
in your template like this:
<div [ngClass]="setClasses()">This div is saveable and special</div>
Zyzle source share