我正在使用角度7的质数。默认情况下,多选组件显示所选值,以逗号分隔。我需要它来显示用#分隔的值。
<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)
]]
}
答案 0 :(得分:1)
您可以使用multiSelect与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>
“模板”部分的“官方”专页中的更多信息: https://www.primefaces.org/primeng/#/multiselect