Angular 涂底漆';s';选择editem';模板不起作用,它总是将选定值设置为';字段';在自动完成中设置的属性

Angular 涂底漆';s';选择editem';模板不起作用,它总是将选定值设置为';字段';在自动完成中设置的属性,angular,typescript,primeng,Angular,Typescript,Primeng,基本上,我正试图利用所选项目模板来实现Priming的自动完成,但不起作用。在下面的代码中,我在“selectedItem”模板中指定以某种方式格式化值。有什么我遗漏的吗 <p-autoComplete [formControlName]="controlModel.id" [forceSelection]="true" [suggestions]="httpSe

基本上,我正试图利用所选项目模板来实现Priming的自动完成,但不起作用。在下面的代码中,我在“selectedItem”模板中指定以某种方式格式化值。有什么我遗漏的吗

<p-autoComplete [formControlName]="controlModel.id"
                                [forceSelection]="true"
                                [suggestions]="httpSearchResult"
                                field="Identifier"
                                (completeMethod)="searchFromUrl($event.query)"
                                (onSelect)="setSearchBoxValue()"
                                [dropdown]="true"
                                [placeholder]="'Select ' + controlModel.displayName"
                                [multiple]="controlModel.multiple">
                    <ng-template let-searchItem pTemplate="item">
                        <ng-container *ngIf="searchItem.DisplayLabel == '' && searchItem.Identifier != ''">
                            <div class="ui-helper-clearfix">
                                <div>{{searchItem.Identifier}}</div>
                            </div>
                        </ng-container>
                        <ng-container *ngIf="searchItem.DisplayLabel != '' && searchItem.Identifier == ''">
                            <div class="ui-helper-clearfix">
                                <div>{{searchItem.DisplayLabel}}</div>
                            </div>
                        </ng-container>
                        <ng-container *ngIf="searchItem.DisplayLabel != '' && searchItem.Identifier != ''">
                            <div class="ui-helper-clearfix">
                                <div>{{searchItem.Identifier}} - {{searchItem.DisplayLabel}}</div>
                            </div>
                        </ng-container>
                    </ng-template>
                    <ng-template let-searchItem pTemplate="selectedItem">
                        <div class="ui-helper-clearfix">
                            <div>{{searchItem.Identifier}} - {{searchItem.DisplayLabel}}</div>
                        </div>
                    </ng-template>
                </p-autoComplete>```

{{searchItem.Identifier}
{{searchItem.DisplayLabel}
{{searchItem.Identifier}}-{{searchItem.DisplayLabel}
{{searchItem.Identifier}}-{{searchItem.DisplayLabel}
```

在线找到解决此问题的解决方法: