это то, что я пытаюсь сделать
Я пытаюсь преобразовать объект в объект из другого класса. Я не знал, как это сделать коротким путем, поэтому я сделал это вдолгий путь, и из-за этого нет никаких причин не работать.Но я получаю ошибку.
**this is the code, tring to convert**
loadDev()
{
console.log("enter to load dev")
for(let i=0; i<this.myserv.childListOfCurrentFamily.length; i++)
{
this.myserv.compleateChildList[i].Id= this.myserv.childListOfCurrentFamily[i].Id
this.myserv.compleateChildList[i].IdFamily= this.myserv.childListOfCurrentFamily[i].IdFamily
this.myserv.compleateChildList[i].Tz= this.myserv.childListOfCurrentFamily[i].Tz
this.myserv.compleateChildList[i].Name= this.myserv.childListOfCurrentFamily[i].Name
this.myserv.compleateChildList[i].BornDate= this.myserv.childListOfCurrentFamily[i].BornDate
this.myserv.compleateChildList[i].Sex= this.myserv.childListOfCurrentFamily[i].Sex
console.log(this.myserv.compleateChildList[i])
}
}
**this is the error, that the convert failed:**
{
core.js:1598 ERROR TypeError: Cannot set property 'IdFamily' of undefined
at LoginComponent.push../src/app/login/login.component.ts.LoginComponent.loadDev (login.component.ts:77)
at SafeSubscriber._next (login.component.ts:101)
at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.__tryOrUnsub (Subscriber.js:253)
at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.next (Subscriber.js:191)
at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._next (Subscriber.js:129)
at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:93)
at MapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/map.js.MapSubscriber._next (map.js:81)
at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:93)
at FilterSubscriber.push../node_modules/rxjs/_esm5/internal/operators/filter.js.FilterSubscriber._next (filter.js:85)
at FilterSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:93)}