Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 基于下拉选择显示表格_Angular_Typescript_Angular Material - Fatal编程技术网

Angular 基于下拉选择显示表格

Angular 基于下拉选择显示表格,angular,typescript,angular-material,Angular,Typescript,Angular Material,我有两个dropdownlist,其中一个在我从中选择一个值后将返回一个对象数组 我希望在选择时动态显示表 <li class="mat-form-field--inline"> <mat-form-field> <mat-label>Sélectionner la Réference de l'application</mat-label> <select [(ngModel)]=&qu

我有两个dropdownlist,其中一个在我从中选择一个值后将返回一个对象数组

我希望在选择时动态显示表

 <li class="mat-form-field--inline">
  <mat-form-field>
    <mat-label>Sélectionner la Réference de l'application</mat-label>
    <select
      [(ngModel)]="selectedObject"
      (change)="getFammille($event.target.value)"
      matNativeControl
    >
      <option
        *ngFor="let application of applications; let i = index"
        [value]="applications[i].reference"
      >
        {{ application.reference }}
      </option>
      &lt;/option>
    </select>
  </mat-form-field>

  <mat-form-field>
    <mat-label>Sélectionner une famille</mat-label>
    <select
      [(ngModel)]="familyName"
      (change)="getCaracteristiques($event.target.value)"
      matNativeControl
    >
      <option
        *ngFor="let famille of familleArray; let i = index"
        [value]="famille.nom"
      >
        {{ famille.nom }}
      </option>
      &lt;/option>
    </select>
  </mat-form-field>
</li>

// Need to Select this field to display the Table
<mat-form-field>
  <mat-label>Sélectionner une famille</mat-label>
  <select
    [(ngModel)]="familyName"
    (change)="getCaracteristiques($event.target.value)"
    matNativeControl
  >
    <option
      *ngFor="let famille of familleArray; let i = index"
      [value]="famille.nom"
    >
      {{ famille.nom }}
    </option>
    &lt;/option>
  </select>
</mat-form-field>

<table mat-table [dataSource]="this.caracteristiques" class="mat-elevation-z8">
  <ng-container matColumnDef="id">
    <th mat-header-cell *matHeaderCellDef>type</th>
    <td mat-cell *matCellDef="let carac">{{ carac.type }}</td>
  </ng-container>

  <ng-container matColumnDef="NumeroOrdre">
    <th mat-header-cell *matHeaderCellDef>champs</th>
    <td mat-cell *matCellDef="let carac">{{ carac.champs }}</td>
  </ng-container>

  <ng-container matColumnDef="Titulaire">
    <th mat-header-cell *matHeaderCellDef>nom</th>
    <td mat-cell *matCellDef="let carac">{{ carac.nom }}</td>
  </ng-container>

  <ng-container matColumnDef="UniteCertifie">
    <th mat-header-cell *matHeaderCellDef>label</th>
    <td mat-cell *matCellDef="let carac">{{ carac.label }}</td>
  </ng-container>

  <ng-container matColumnDef="Etat">
    <th mat-header-cell *matHeaderCellDef>valeurs</th>
    <td mat-cell *matCellDef="let carac">{{ carac.valeurs }}</td>
  </ng-container>
  <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
  <tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
</table>
  • Sélectionner la Réreference de l’应用 {{application.reference}} /选项> 家庭选择 {{famille.nom}} /选项>
  • //需要选择此字段以显示表格 家庭选择 {{famille.nom}} /选项> 类型 {{carac.type} 冠军 {{carac.champs}} 笔名 {{carac.nom}} 标签 {{carac.label} 瓦勒尔斯 {{carac.valeurs}}
    目前,我有一个错误,因为在选择第二个字段之前,我无法找到忽略该表的方法


    有没有办法添加此条件?

    *ngIf=“caracteristiques”
    添加到
    中是否有帮助:

    
    
    最好是一个完整的组件示例(html+typescript)

    <table  *ngIf="caracteristiques" mat-table [dataSource]="this.caracteristiques"   class="mat-elevation-z8">