使用Angular从select中的外键获取数据

时间:2019-11-25 16:19:43

标签: angular

我试图根据外键(关系)构建一个选择以从另一个表中获取数据, 在这种情况下,根据所选类别的参数

数据库模型的附加图像示例

.ts


  parametro = new Parametros();
  parametros : Parametros[];
getParametros(): void {
    this.dataService
      .getParametros()
      .then(parametros => this.parametros = this.parametros);
  }

这是我的选择

component .html

  <mat-select [(ngModel)]="selectedValue" name="examenCat">
    <mat-option (click)="selectedCat(categoria.id)" *ngFor="let categoria of categorias" href="#modalFormulario" data-toggle="modal" >
      {{categoria.nombreCat}}
    </mat-option>
  </mat-select>

获取服务示例

service.ts

    getParametros(): Promise<Parametros[]> {
        return this.http.get(this.baseurl + '/parametro?format=json', { headers: this.headers })
            .toPromise()
            .then(response => response.json() as Parametros[])
    }

Model DB

0 个答案:

没有答案