小编Bha*_*an 的帖子

如何在 *ngFor 中使用 mat-select-trigger

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

我在 mat-options 中尝试过*ngFormat-select-trigger但它不起作用。

    <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>
Run Code Online (Sandbox Code Playgroud)

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

angular-material angular

8
推荐指数
1
解决办法
1万
查看次数

标签 统计

angular ×1

angular-material ×1