gpt4 book ai didi

How to auto-populate the custom library component with previously selected value?(如何使用以前选择的值自动填充定制库组件?)

转载 作者:bug小助手 更新时间:2023-10-28 11:43:48 27 4
gpt4 key购买 nike



I want to pre-populate the selected value in the <ds-select> custom library component for an edit functionality to perform.
I have tried all possible ways, but have no idea of any predefined properties of this component that can help me to achieve this.
The HTML code is as follows.

我希望预先填充 定制库组件中的选定值,以便执行编辑功能。我尝试了所有可能的方法,但不知道该组件的任何预定义属性可以帮助我实现这一点。该HTML代码如下所示。


<ds-select
id="dataList"
class="form-control"
isMultiselect
formControlName="dataList"
[options]="availableData" <!-- Use the entire list as options -->
[selectedValues]="preselectedData" <!-- Set the selected values -->
>
</ds-select

.ts code

.TS代码


const selectedIds = selectedValues.map(item => item.id);
this.preselectedData = availableData.map(selectedIds => selectedIds.includes(selectedIds.id.tostring()));

The JSON data for
selectedId

选定ID的JSON数据


const selectedValues = [
{
"id": "42",
"label": "abc"
},
{
"id": "11",
"label": "fss"
},
{
"id": "15",
"label": "awe"
}
];

availableData json

AvailableData json


{
"availableData:[
{
"id":1,
"name":"Data A",
"desc":"Data A desc",

},
{
"id":2,
"name":"Data B",
"desc":"Data B desc",

},
{
"id":10,
"name":"Data D",
"desc":"Data D desc",

},
],

}

help in advance would be appreciated.

如能提前提供帮助,将不胜感激。


更多回答
优秀答案推荐
更多回答

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com