Reputation: 1
I want to display a button if paymentdone
is due.
Below is my HTML code for Angular using ngIf:
<tr>
<td class="table-id">{{app_list.testbookingmasterid}}</td>
<td>{{app_list.userid}}</td>
<td>{{app_list.patientname}}</td>
<td>{{app_list.paymentdone}}
<ng-container *ngIf="{{app_list.paymentdone}}==='due'">
<button type="button" class="btn btn-primary btn-xs" data-toggle="modal" (click)="demo(app_list.testbookingmasterid,app_list.userid)" ><i class="fa fa-edit"></i> Process</button>
</ng-container> </td>
<td>{{app_list.comments}}</td>
</tr>
But it seems ngIf is not working.
How can I do it? Can anyone help me in this?
Upvotes: 0
Views: 88
Reputation: 645
you just have to remove bracet in *ngIf and make it simple
*ngIf="app_list.paymentdone==='due'"
Upvotes: 0
Reputation: 24464
ngIf syntax look like this *ngIf="exprestion" , the exprestion can be a check component property if it value truthy or comparison expression like property === value
in your case just update the exprestion to this
*ngIf="app_list.paymentdone === 'due'"
not if
app_list
is hasn't initialize or the value will be a result of async operation you need to use '?.' (safe navigation operator) operator so you dont got an error can't read paymentdone of undefined
final solution look like this
<ng-container *ngIf="app_list?.paymentdone === 'due' ">
...
</ng-container>
Upvotes: 0
Reputation: 1
There is no need to use interpolation.
Try the following
<ng-container *ngIf="(payment==='due')">
hello payment mode due
</ng-container>
Working Example https://stackblitz.com/edit/angular-8anxaf
Upvotes: 0
Reputation: 21
You don't need bracet in an *ngIf
.
You only have to do =>
*ngIf="app_list.paymentdone==='due'"
Upvotes: 2