export class ShopModel {
public id: number;
public name: string;
public email: string;
public phone: string;
public website: string;
public address: string;
public gst_number: string;
public pan_number: string;
public tan_number: string;
public plan_id: number;
public status: number = 1;
public users: UserModel[];
public customers: CustomerModel[];
public categories: CategoryModel[];
public plan: PlanModel;
public static getDummyModel(): ShopModel {
return new ShopModel();
}
}
This represents my Data model with various properties and associations.
{
"shop": {
"name": "Develop Shop",
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="16657e79252225226656727360737a7966387465">[email protected]</a>",
"phone": "2343",
"website": "dtewrtyty",
"address": "rgtyyiuyouyip",
"gst_number": "eytyw",
"pan_number": "rywtywe",
"tan_number": "ryeyru",
"plan_id":1,
"users_attributes": [{
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="73001b1c0333171605161f1c035d1100">[email protected]</a>",
"role": "user"
}, {
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e5968d8a95d7a581809380898a95cb8796">[email protected]</a>",
"role": "staff"
}]
}
}
I am looking to send this JSON object via an HTTP POST request to the server.
To achieve this, I need to modify the users array in the data object to users_attributes before sending it.
If you have any suggestions on how best to achieve this using Angular 6, please advise me accordingly. Thank you!