Reputation: 345
I am comparing two conditions here and trying to display a textbox based on the condition. If two dates are matching and task also same then i have to display the time entered in the textbox from database if it is already entered, if not i need to display am empty text box. But its not working. Can any one please help me?
<div *ngFor="let userTimesheet of timesheet">
<div *ngIf="(((currentSun | date:'MM/dd/yyyy') === (userTimesheet?.task_date | date:'MM/dd/yyyy')) && (user.task.task_id == userTimesheet?.task))); else notMatching " >
<input type="text" value="{{ userTimesheet.task_totaleffort}}" formControlName="sundaytime">
</div>
<ng-template #notMatching>
<input type="text" value="" formControlName="sundaytime">
</ng-template>
</div>
Upvotes: 0
Views: 142
Reputation: 7799
You could directly use a ternary operator in the input
value attribute :
<div *ngFor="let userTimesheet of timesheet">
<input
type="text"
[value]="(((currentSun | date:'MM/dd/yyyy') === (userTimesheet?.task_date | date:'MM/dd/yyyy')) && (user.task.task_id == userTimesheet?.task)))
? userTimesheet.task_totaleffort : ''"
formControlName="sundaytime">
</div>
Upvotes: 1