My Meal Class (server-side)
public class Meal {
public Meal()
{
Fruits = new List<Fruit>();
}
public int Id { get; set; }
public string Name { get; set; }
[ForeignKey("Fk_VendorId")]
public virtual Vendor Vendor { get; set; }
public int Fk_VendorId { get; set; }
//collection
public virtual ICollection<Fruit> Fruits { get; set; }
}
Form Html:
<div ng-controller="MealCtrl>
<select ng-model="meal.Id" ng-options="meal.Id as meal.Name for meal in Meals"></select>
</div>
<div ng-controller="FruitCtrl>
<select ng-model="???" ng-options="fruit.Id as fruit.Name for fruit in fruits"></select>
</div>
<div ng-controller="VendorCtrl>
<select ng-model="???" ng-options="vendor.Id as vendor.Name for vendor in vendors"></select>
</div>
Question:
How to pass the selected associated class [Vendor] and associated collection [Fruits] to the Meal class on submit?
Move the closing MealCtrl div to the end and add meal.FK_VendorId as the ng-model for vendor.
<div ng-controller="MealCtrl>
<select ng-model="meal.Id" ng-options="meal.Id as meal.Name for meal in Meals"></select>
<div ng-controller="FruitCtrl>
<select ng-model="???" ng-options="fruit.Id as fruit.Name for fruit in fruits"></select>
</div>
<div ng-controller="VendorCtrl>
<select ng-model="meal.Fk_VendorId" ng-options="vendor.Id as vendor.Name for vendor in vendors"></select>
</div>
</div>