我如何使用 Angular 5 将数组对象转换为特定的 JSON 格式?
How i convert array object to specific JSON format using Angular 5?
来自 Material Table i select 行使用复选框并登录控制台 -
setTimeout(() => {
this.selectedRows = this.selection.selected;
console.log(this.selectedRows);
});
0: {position: 12, name: "Magnesium", weight: 24.305, symbol: "Mg"}
1: {position: 14, name: "Silicon", weight: 28.0855, symbol: "Si"}
我如何将其转换为使用位置值
"ContactIds":["12","14"]
您可以像这样创建一个新对象:
const positions = { ContactIds : this.selectedRows.map(r => r.position) }
你也可以使用选集,它现在在@material/cdk
import {SelectionModel} from '@angular/cdk/collections';
export class....
selection = new SelectionModel<interface>(true, []);
在您的 html 中,选择一行时
selection.toggle(row)
如果你不会用它,请告诉我,我看看能不能在 stackblitz 中做一个例子。
来自 Material Table i select 行使用复选框并登录控制台 -
setTimeout(() => {
this.selectedRows = this.selection.selected;
console.log(this.selectedRows);
});
0: {position: 12, name: "Magnesium", weight: 24.305, symbol: "Mg"}
1: {position: 14, name: "Silicon", weight: 28.0855, symbol: "Si"}
我如何将其转换为使用位置值
"ContactIds":["12","14"]
您可以像这样创建一个新对象:
const positions = { ContactIds : this.selectedRows.map(r => r.position) }
你也可以使用选集,它现在在@material/cdk
import {SelectionModel} from '@angular/cdk/collections';
export class....
selection = new SelectionModel<interface>(true, []);
在您的 html 中,选择一行时
selection.toggle(row)
如果你不会用它,请告诉我,我看看能不能在 stackblitz 中做一个例子。