Riddhi Valecha

Riddhi Valecha

  • 443
  • 3.3k
  • 411k

Angular - Checkbox in table and iterate through the items

Mar 8 2021 6:27 PM
Dear Team,
 
I have made a service and html file in Angular.
 
I need to include a checkbox in the table and iterate through the items.
 
File - p.components.html
  1. <h1>Pending Assets</h1>  
  2. <div class="container">  
  3. <table class='table table-striped'>  
  4. <thead>  
  5. <tr>  
  6. <th>Computer.ComputerType</th>  
  7. <th>Model.Brand.Name</th>  
  8. <th>Model.Name</th>  
  9. <th>Computer.TcpIpHostName</th>  
  10. <th>Asset.SerialNo</th>  
  11. <th>User.UserName</th>  
  12. <th>RIL_Inventoried_User.UserName</th>  
  13. <th>Asset.Field1</th>  
  14. </tr>  
  15. </thead>  
  16. <tbody>  
  17. <tr *ngFor="let pa of pendingasset">  
  18. <td>{{ pa.computerComputerType }}</td>  
  19. <td>{{ pa.modelBrandName }}</td>  
  20. <td>{{ pa.modelName }}</td>  
  21. <td>{{ pa.computerTcpIpHostName }}</td>  
  22. <td>{{ pa.assetSerialNo }}</td>  
  23. <td>{{ pa.userUserName }}</td>  
  24. <td>{{ pa.rIL_Inventoried_UserUserName }}</td>  
  25. <td>{{ pa.assetField1 }}</td>  
  26. <td> {{ pa.modelName }} </td>  
  27. </tr>  
  28. </tbody>  
  29. </table>  
  30. </div>  
File - p.component.ts
  1. import { Component, Inject, OnInit } from '@angular/core';  
  2. import { HttpClient } from '@angular/common/http';  
  3. import xml2js from 'xml2js';  
  4. import { HttpHeaders } from '@angular/common/http';  
  5. import { Observable } from 'rxjs';  
  6. //import { AgGridModule } from "ag-grid-angular/main";  
  7. //import { GridOptions } from "ag-grid/main";  
  8. @Component({  
  9. selector: 'app-pendingassets',  
  10. templateUrl: './pendingassets.component.html'  
  11. //styleUrls: ['./pendingassets.component.css']  
  12. })  
  13. export class PendingAssets {  
  14. public pendingasset: pendassets[];  
  15. constructor(http: HttpClient, @Inject('BASE_URL') baseUrl: string) {  
  16. http.get<pendassets[]>(baseUrl + 'api/PendingAssetsAPI').subscribe(result => {  
  17. this.pendingasset = result;  
  18. }, error => console.error());  
  19. }  
  20. }  
  21. interface pendassets {  
  22. ComputerComputerType: string;  
  23. ModelBrandName: string;  
  24. ModelName: string;  
  25. ComputerTcpIpHostName: string;  
  26. AssetSerialNo: string;  
  27. UserUserName: string;  
  28. RIL_Inventoried_UserUserName: string;  
  29. AssetField1: string;  
  30. }  

Answers (5)