Angular 5 - Angular Material - 在选择国家后显示区域

时间:2018-04-02 09:35:33

标签: angular-material angular5

在我的angular5应用程序中,我有这样的形式:

this.form = this.formBuilder.group({    
  institution: ['', [Validators.required, Validators.minLength(2)]],
  color: [''],
  ...
  addressesWithProducts: this.formBuilder.array([])
});

为了添加新的 addressWithProducts ,我使用此方法:

addAddress() {
    let addressWithProducts = this.formBuilder.group({
      address: this.formBuilder.group({
        ...
        country: ['', [Validators.minLength(2)]],
        provinceType: ['', [Validators.minLength(2)]],
        provinceTypesOfAddressWithProducts: [['test1', 'test2', 'test3']],
        ...
      })
    });
    let addressesWithProducts: FormArray = 
    this.form.controls['addressesWithProducts'] as FormArray;
    addressesWithProducts.push(addressWithProducts);
}

我将使用

显示 test1,test2和test3
<form [formGroup]="form" (ngSubmit)="onSubmit()">
    ...
    <div formArrayName="addressesWithProducts">
        <mat-form-field style="width:95%">
            <mat-select placeholder="District" formArrayName="provinceTypesOfAddressWithProducts">
                <mat-option *ngFor="let provinceType of provinceTypesOfAddressWithProducts" [value]="provinceType">
                    {{provinceType | translate}}
                </mat-option>
            </mat-select>
        </mat-form-field>

但是select中没有显示任何值。有没有人有任何暗示才能让它发挥作用?

0 个答案:

没有答案