我有一个FormArray,它有属性productcode .

<mat-form-field>
    <mat-select placeholder="product code">
      <mat-option *ngFor="let product of products"[value]="product.code">
        {{product.val}}
       </mat-option>
     </mat-select>
  <mat-error>product code should be unique</mat-error>
</mat-form-field>

我添加了一个按钮,它在表单数组中预先添加了第一个新的记录值 . 一旦我点击添加按钮以编程方式在表单数组中插入新记录,mat-select就会出现在屏幕上 . 但在mat-error中不显示重复的验证消息 . 如果我们手动选择值,那么只有它可以工作 .