我有一個僱員對象,我想複製一些值到一個新的對象。我正在使用Typescript來複制它們,但我得到錯誤。Angular 2 - 無法將值從一個對象複製到另一個使用打字稿
打字稿代碼:
employee = [
{ "empId": "59C", "empDesc": "Software","location":"Dallas"},
{ "empId": "AMI", "empDesc": "Hardware", "location":"San Francisco"}
];
companies : any;
for (let c of this.employee) {
this.companies.push({
empDesc: c.empDesc,
empId: c.empId
})
};
console.log("Companies",this.companies);
Plunker代碼鏈接:
https://plnkr.co/edit/CnBR4JouNhzH3DWm7QCo?p=preview