I have a property details which is a nested object.
On clicking sign-in i get a form object which has values i want to set the values from the form into the nested object. Why cannot we use the normal .(dot) operator or the []
to chain and access the nested objects and their properties.
export class AppComponent {
details:{
city:string,
dates:{
date:Date,
data:{
name:string,
comment:string
}[]
}[]
}
// this function is executed on submit of the form
onSignin(form:NgForm){
console.log(form)
this.details.city=form.value.city; // cannot set property 'city' of undifined
console.log(this.details)
}
}