I am performing an instanceof
check in *ngIf
.
<span *ngFor="let element of elements">
<app-text *ngIf="element instanceof BlueElement"></app-text>
</span>
Unfortunately, instanceof
cannot be used, because it is defined by javascript.
Therefore I created my own instanceOf
method:
instanceOf<T,C>(value:T,clss:C){
if (value instanceof C){
return true;
}else{
return false;
}
}
I am getting an error; C is only defined as a type, but is being used as a value here.
How should I rewrite the generic instanceOf()
function?