Reputation: 6452
I am using primeng with angular 7. By default the multiselect component displays the selected value separated by comma. i need this to display values separated by #.
<p-multiSelect formControlName="selectedLayers"
[options]="layerList"
[id]="'selectedLayers'"
[selectedItemsLabel]="'{0} layers selected'">
</p-multiSelect>
ngOnInit(): void {
this.groupLayerForm = this.formBuilder.group({
selectedLayers: [[], [
ArrayValidator.minLengthArray(1)
]]
}
Upvotes: 3
Views: 7135
Reputation: 3149
You can use the templating options that primeng multiSelect has with pTemplate="selectedItems"
:
<p-multiSelect formControlName="selectedLayers"
[options]="layerList"
[id]="'selectedLayers'"
[selectedItemsLabel]="'{0} layers selected'">
<ng-template let-selectedLayers pTemplate="selectedItems">
<ng-container *ngFor="let selectedLayer of selectedLayers;">{{selectedLayer}}#
</ng-container>
</ng-template>
</p-multiSelect>
More info in the oficial primeng page in the Templating section: https://www.primefaces.org/primeng/#/multiselect
Upvotes: 3