如何将mat-select-trigger与*ngFor一起使用


mat-option具有*ngFor,我在其中显示{{some text}}和一个图标,因此,在选择任何一个选项时,{{some text}}和图标文本都会显示在mat-form-field中。例如:如果我有一个文本"bbnh"和信息图标。选择此选项时,我希望它仅显示"bbnh" image_for_the_above

我在mat-select-trigger上尝试了*ngFor,就像在mat-options中一样,但它不起作用。

    <mat-form-field>
      <mat-select  placeholder="Select offer" formControlName="promo">
        <mat-select-trigger>
          {{ item.promo_code }} //Error occuring in this line
        </mat-select-trigger>
        <mat-option *ngFor="let item of promotions" [value]="item"
          >{{ item.promo_code }}
          <i class="material-icons">
            info
          </i>
        </mat-option>
      </mat-select>
    </mat-form-field>

未定义标识符'item'。组件声明、模板变量声明和元素引用不包含此类

转载请注明出处:http://www.gxainuo.com/article/20230526/1080223.html