1

I am using multiselect component from prime ng. I am trying to change the label of the multiselect dropdown but it does not work. Please find my code below:

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

How do I change default label for the multiselect component ?

Thanks

Ashy Ashcsi
  • 1,529
  • 7
  • 22
  • 54

1 Answers1

0

Use defaultLabel="Your Label" or [defaultLabel]="'Your Label'"

Try like this:

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

Note: If you have the string in the variable,

Use: [defaultLabel]="labelVariable"

If it is a hardcoded string, then

Use: defaultLabel="Your Label"

Adrita Sharma
  • 21,581
  • 10
  • 69
  • 79
  • The version you mentioned above without square brackets worked. But if the cities array is getting modified by some other external sources, the label disappears. So, back to square one. - thanks – Ashy Ashcsi Apr 20 '20 at 11:22
  • yeah, it worked. whenever I am resetting the dropdown data, I use this.multi._defaultLabel="label" along with your code. thanks. – Ashy Ashcsi Apr 22 '20 at 13:19