灌注多选显示选择的值,这些值用特殊字符分隔,而不是默认逗号

时间:2019-04-08 08:43:07

标签: angular7 primeng

我正在使用角度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)
            ]]
        }

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