在angular 5中,如何仅使用到ListB的行列索引获取静态listA记录。不使用component.ts文件中的Column标头。您能帮帮我吗
ListA=[{Id:0,Name:Babu},{Id:1,Name:raju}] // here ListA is static list.
新的ListB将采用
的形式[{A:1,B:Babu},{A:2,B:raju}] // here B column record as ListA Column "Name" record.
答案 0 :(得分:0)
You can use the array.map function to generate your new array:
let listB = listA.map((item) => {A: item.Id, B:item.Name});
By the way, unless your Name property values is a variable, you should add quotes around it. Like this:
ListA=[{Id:0,Name:"Babu"},{Id:1,Name:"raju"}]
Hope this helps...