Reputation: 73
reservedcoders: ReservedCoders[];
export class ReservedCoders{
constructor(
public coderID:number
){ }
}
mycoder is an array
<td>
<div *ngIf="reservedcoders.find(s => s.coderID == mycoder.svUserID); else notEqual">
<button type="button" (click)="releasePopUp(mycoder.svUserID,mycoder.name)" class="btn btn-primary">Release</button>
<button type="button" (click)="addAdditionalPopUp(mycoder.svUserID,mycoder.name)" class="btn btn-primary">Add 10%</button>
</div>
<ng-template #notEqual>
<button type="button" (click)="releasePopUp(mycoder.svUserID,mycoder.name)" disabled class="btn btn-primary">Release</button>
<button type="button" (click)="addAdditionalPopUp(mycoder.svUserID,mycoder.name)" disabled class="btn btn-primary">Add 10%</button>
</ng-template>
</td>
Upvotes: 7
Views: 6455
Reputation: 30088
I'm not sure what the exact problem is, but I have found in the past that somewhat complex expressions do often fail in *ngIf bindings.
The likely best solution is to modify your code to call a simple method in your component, and implement the "find" in that method.
So, for instance, implement this in your component:
public coderIdIsReserved(): boolean {
return this.reservedcoders.find(s => s.coderID === mycoder.svUserID) ;
}
and change your template to:
<div *ngIf="coderIdIsReserved(); else notEqual">
Upvotes: 7