0
如果我有一個對象車:添加與.MAP(屬性)
{
make: "Chevy",
model: "Sonic"
type: {
id: 1,
name: "Tiny"
}
}
,我想操縱對象添加TYPEID屬性:
{
make: "Chevy",
model: "Sonic"
type: {
id: 1,
name: "Tiny"
},
typeId: 1
}
哪你會使用rxjs操作符,假設你有這些對象的數組?這就是我試圖避免:
someArray.map(item => ({
make: item.make,
model: item.model,
type: item.type,
typeId: item.type.id
}));
地圖上如果您'只是加入,爲什麼不'someArray.forEach(o => o.typeId = o.type.id)' – adeneo
你到底想要避免什麼? –
重寫整個模型,因爲我使用的模型比這輛車大得多。 ;-) – wolfhoundjesse