mat-option 有*ngFor
并且我正在显示{{some text}}
一个图标,因此,在选择任何一个选项时,{{some text}}
和 图标文本都会显示在mat-form-field
. 例如:如果我有一个文本"bbnh"
和信息图标。选择此选项时,我希望它只显示"bbnh"
image_for_the_above
我在 mat-options 中尝试过*ngFor
,mat-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'
未定义。组件声明、模板变量声明和元素引用不包含这样的