angular - Angular Material 占位符不适用于 @Input
问题描述
我正在使用角度材料。在我的父组件中
<app-multiselect
[optionsList]="propertyTypeList"
[multiple]=true
[placeholder]="Select"
></app-multiselect>
在 .ts 文件的子组件中,我使用的是 @Input
@Input() placeholder: string;
在我的子 html 文件中
<mat-form-field>
<mat-select
[multiple]="multiple"
[placeholder]="placeholder">
<mat-option
*ngFor="let item of optionsList"
[value]="item">{{item}}</mat-option>
</mat-select>
</mat-form-field>
我得到的是“占位符”而不是“选择”。
有任何想法吗?谢谢 :)
解决方案
由于您将字符串作为输入传递,因此需要将其包含在''
<app-multiselect [placeholder]="'Select'" ></app-multiselect>
当你绑定时,你应该使用字符串插值作为{{}}
<mat-select placeholder="{{placeholder}}">
推荐阅读
- python - 如何在列表列表中的单个项目中添加单引号?
- r - 按组计算字符串值出现的次数
- reactjs - 对象作为 React 子对象无效(发现时间:Mon Aug 23 2021 19:00:04 GMT+0300)
- powershell - 我正在尝试使用 Powershell 在 win server 2012r2 机器上创建自签名证书。目的是将流量从 HTTP 重定向到 HTTPS
- python - 如何正确使用括号?
- wso2-am - wso2 api manager 3.2.0如何在Oracle RAC环境中配置oracle数据库
- asp.net - Oracle ManagedDataAccess 4.122.1.0 可以连接到 Oracle server 19c 吗?
- excel - 如何使用 Excel VBA 将当前工作表保存为 PDF 和 Outlook 电子邮件?
- html - 如何在纯 CSS 中创建拆分背景颜色布局
- scope - 如何在 vb.net 中使用 largescope 声明局部变量