Search code examples
angularprimengmulti-selectprimeng-dropdowns

change defult label of prime ng multiselect


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


Solution

  • 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"