I am trying to create nested object as below
myForm value:
{
"name": {
"firstname":"abc",
"lastname":"xyz"
},
"address": {
"street": "assdasdasdsa",
"postcode": "8000"
}
}
In interface, there is option to specify string,number, array types syntax
I tried below options but no luck and it is throwing error "ERROR Error: Cannot find control with name:" (workarounds from SO and others didn't help)
export interface Customer {
name: {
firstname: string;
lastname: string;
};
addresses: Address[];
}
export interface Address {
street: string;
postcode: string;
}
Could you please provide me options to specify object as mentioned above?
Plunker- https://embed.plnkr.co/hQ6RtzCfPosfQl4HlbZQ/
In Angular 1, it was easy with scope object and using ng-model as "myForm.name.firstname"
Codepen tried in angular1 - https://codepen.io/nagasai/pen/mmYgbr and trying to replicate same in angular 2
Name:export interface Name {firstname: string; lastname:string}address:export interface Address {street: string;postcode: string;}and customer:export interface Customer{name: Name;addresses:Address[]}