Reputation: 856
I have one model with following properties
{
Name:String,
Id:Number,
Store:{
Name:String,
City:String,
State:String
}
}
How can I define model with this structure in angular2 with typescript ?
Upvotes: 0
Views: 402
Reputation: 1059
Just define 2 interfaces with your required values.
export interface ParentModel {
Name: string;
Id: number;
Store: ChildModel
}
export interface ChildModel {
Name: string;
City: string;
State: string;
}
Depending on how you want to set it up these can be in the same file or two separate files, if you are putting them in separate files just remember to import the child into the parent.
Hope that helps
Upvotes: 3