Forums - C# Corner

Forum guidelines
Mandar Shinde

Mandar Shinde

  • 1.5k
  • 267
  • 3.7k

Regarding ngIf and ngIfElse

Feb 18 2019 2:53 AM
Dear All,
I am beginner in Angular 5 and ASP .net MVC. I was creating one web page using Angular 5.
In a table I was printing data which comes from database with table name tblStudent.
In that table there is last last column with name Active which is Boolean value.
What I am doing with help Angular 5 I am just showing one checkbox enabled or disabled.
If I am getting value true then I should able to check the checkbox.
Here is my code which won't work :
  1. <table>   
  2. <tr  
  3.               *ngFor="let item of items | paginate: { itemsPerPage: 10, currentPage: p };  let i = index">  
  4.               <td> {{ 10 * (p - 1) + i + 1}} </td>  
  5.               <td>  
  6.                 <ng-template [ngIf]="item.Activate == true" [ngIfElse]="elseBlock">  
  7.                   <div>  
  8.                     <input type="checkbox" (change)="selected(item, $event)">  
  9.                   </div>  
  10.                 </ng-template>  
  11.                 <ng-template #elseBlock>  
  12.                   <div>  
  13.                     <input type="checkbox" (change)="selected(item, $event)" disabled>  
  14.                   </div>  
  15.                 </ng-template>  
  16.               </td>  
  17.               <td>{{item.Group_Name}}</td>  
  18.               <td>{{item.Description}}</td>  
  19.               <td>  
  20.                 <i class="material-icons icon-Green" id="cursor" (click)=" ViewMisc(item.ID,content) ">  
  21.                   border_color</i>  
  22.               </td>  
  23.             </tr>  
  24. </table>  
Please help me with easy solution.
Thanking you in advance

Answers (2)