Typescript Angular 8动态表单的post数据

Typescript Angular 8动态表单的post数据,typescript,angular8,Typescript,Angular8,如何将所有mat select中的数据发布到控制器 <form class="example-form"> <ng-container *ngFor="let drillBitProperties of DrillBitProperties$"> <mat-form-field class="example-full-width" *ngIf="drillBitProperties.type=='dropdown'">

如何将所有mat select中的数据发布到控制器

<form class="example-form">
    <ng-container *ngFor="let drillBitProperties of DrillBitProperties$">
        <mat-form-field class="example-full-width" *ngIf="drillBitProperties.type=='dropdown'">
            <mat-label>{{drillBitProperties.label}}</mat-label>
            <mat-select>
                <mat-option *ngFor="let prop of drillBitProperties.options" [value]="prop">
                    {{prop}}
                </mat-option>
            </mat-select>
        </mat-form-field>
        <mat-form-field class="example-full-width" *ngIf="drillBitProperties.type=='int'">
            <input matInput placeholder="{{drillBitProperties.label}}" type="number">
        </mat-form-field>
    </ng-container>
    <button mat-button (click)="cancelDialog()">Cancel</button>
    <button mat-button (click)="sendData()">Post</button>
</form>
.ts

在模板中:

<mat-select #select>
}

<mat-select #select>
@ViewChild("select", {static: false}) select: MatSelect;

sendData() {
   const data = this.select.getOption()
}
you can try like this also

     <select (change)="onCountrySelectionChange($event.target.value)" formControlName="Country_ID">
              <option value="0">--Select--</option>
              <option *ngFor="let country of allCountry" value={{country.id}}>{{country.name}}</option>
            </select>

onCountrySelectionChange(countryId: string) {
this.FillStates(countryId);
this.selectedCountryID = countryId;}

private FillStates(countryId: string) {
this.commonDropdown.getStates(countryId).subscribe((data: {}) => {
  this.allState = data;
  this.allCity = null;
});