【问题标题】:change defult label of prime ng multiselect更改primeng多选的默认标签
【发布时间】:2020-04-20 11:05:47
【问题描述】:

我正在使用来自 prime ng 的多选组件。我正在尝试更改多选下拉列表的标签,但它不起作用。请在下面找到我的代码:

                <p-multiSelect [options]="cities" [defaultLabel]="does not work" styleClass="citiesClass" (onChange)="onChange($event)">
                </p-multiSelect>

如何更改多选组件的默认标签?

谢谢

【问题讨论】:

  • 您试过提供的解决方案了吗?

标签: angular primeng multi-select primeng-dropdowns


【解决方案1】:

使用defaultLabel="Your Label"[defaultLabel]="'Your Label'"

试试这样:

<p-multiSelect [options]="cities" defaultLabel="Your Label" styleClass="citiesClass" (onChange)="onChange($event)">
</p-multiSelect>

注意:如果变量中有字符串,

使用:[defaultLabel]="labelVariable"

如果是硬编码字符串,那么

使用:defaultLabel="Your Label"

【讨论】:

  • 您上面提到的没有方括号的版本有效。但如果城市数组被其他一些外部来源修改,标签就会消失。所以,回到第一方。 - 谢谢
  • 是的,它奏效了。每当我重置下拉数据时,我都会使用 this.multi._defaultLabel="label" 以及您的代码。谢谢。
猜你喜欢
  • 2021-03-14
  • 1970-01-01
  • 2015-07-08
  • 1970-01-01
  • 2016-12-28
  • 2016-08-22
  • 1970-01-01
  • 1970-01-01
  • 2018-07-26
相关资源
最近更新 更多