JSON
K
管道:
{
"bloodGroup":[
{"Id":1, "Value":"O +ve", "Description":"OPositive"},
{"Id":2, "Value":"O -ve", "Description":"ONegative"},
{"Id":3, "Value":"AB +ve", "Description":"ABPositive"}
],
"Gender":[
{"Id":1, "Value":"Male", "Description":"Male"},
{"Id":2, "Value":"Female", "Description":"Female"}
]
}
查找类(由nswag自动生成):
transform(aList: Lookup[], lookUpName: string): Lookup[] {
if (!aList || !lookUpName || aList.length === 0) {
return aList;
}
return Array.of(aList[lookUpName])
}
HTML:
export interface ILookup {
name?: string | undefined;
value?: string | undefined;
description?: string | undefined;
}
选择不绑定必需的值。我在做什么错了?
答案 0 :(得分:1)
将Array.of(aList[lookUpName])
更改为aList[lookUpName]
。一切都会正常。
transform(aList: Lookup[], lookUpName: string): Lookup[] {
if (!aList || !lookUpName || aList.length === 0) {
return aList;
}
return aList[lookUpName];
}