将动态值读入 ng-select

Reading a dynamic value into ng-select

您好,我的应用程序正在尝试为不同的组件创建一个具有不同下拉菜单的动态菜单。例如,当我初始化一个组件时,我从一个看起来像

的 api 请求一个 object
column: 3
corresponding_column: "sku__brand"
field_name: "Brands"
id: 9
list_name: "list1"
param: "brand"
parent: ""
report_type: "all_orders"
request_type: "GET"
row: 2
selected_items_name: "selectedItems5"
settings_name: "dropdownSettings1"
show: 1
show_value: "Brands"
type: "Dropdown"

然后我尝试将我的 object 读入 ng-select 字段

<div *ngFor="let x of row2">
                <div *ngIf="x.type=='Dropdown' &&  x.field_name!='dropdown'">
                  
                    <ng-select *ngIf='Advanced==true' formControlName="search_type_value" class="second-row-box"
                      placeholder=x.field_name [items]=x.list_name bindLabel="itemName" bindValue="id"
                      [(ngModel)]=x.selected_item_name [multiple]="true" [selectableGroup]="true"
                      [closeOnSelect]="false" [maxSelectedItems]="1" (click)='send_request_1("ASIN")'>
                      <ng-template ng-header-tmp>
                        <button (click)="selectAll(list1)">Select all</button>
                        <button (click)="unselectAll()">Unselect all</button>
                      </ng-template>
                      <ng-template ng-footer-tmp>
                        Selected count: {{selected.length}}
                      </ng-template>

                    </ng-select>
                 
                </div>
              </div>

我得到的是

我想要的是x.field_name成为品牌

placeholder 更改为 [placeholder] - 这将其标记为 angular 以解释为输入并且 ng-select 组件获取传递的值(而不是简单的字符串)

您可以通过转到 source code

来判断它是该组件的真实输入