I am facing a unique situation that may seem a bit strange. I have a form that needs to edit/update information from different objects, such as services.
My goal is to use ng-model to link input fields to their respective objects, but when the form is submitted, I need to convert Angular's Form object into a formData object for POSTing. Has anyone done this before without tedious looping?
HTML
<form name="Ctrl.form" ng-submit="Ctrl.submit()" ng-controller="MyController as Ctrl">
<input type="text" name="full_name" ng-model="Ctrl.user.fullName">
<input type="text" name="cart_total" ng-model="Ctrl.cart.gross_total">
<input type="city" name="city" ng-model="Ctrl.dropship.city">
</form>
Controller
this.user = User.getData();
this.cart = Cart.get();
this.dropship = User.addressBook.getDropShip();
this.submit = function() {
// transform this.form into formData
}
Does this all make sense? Am I overlooking something?
Thank you! Sincerely
Edit: The form gathers information from multiple objects, but not every property can be POSTed. I hope this clarifies things.