HTML
<span [ngClass]="{
'fas fa-star' : isSelected,
'far fa-star' : !isSelected
}"
(click)="OnClick()">
</span>
typescript
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
@Component({
selector: 'app-one-component',
templateUrl: './one-component.component.html',
styleUrls: ['./one-component.component.css']
})
export class OneComponentComponent implements OnInit {
@Input() isSelected : boolean;
@Output() change = new EventEmitter();
constructor() { }
ngOnInit() {
}
OnClick(){
this.isSelected= !this.isSelected;
this.change.emit(this.isSelected);
}
}
while clicking icon partial class were loaded like fas or far after space no class was added.