I have an asp.net mvc application where I do some calculations based on what is selected in a selection box:
@model ProductOrderViewModel
...
<select id="unitSelectionBox"
name="@Html.NameFor(x => x.SelectedUnit)" class="form-control" ng-model="pricePerUnit">
@foreach (var productUnit in Model.Product.ProductUnits)
{
<option value="@productUnit.Id" ng-true-value="@productUnit.Price">
@productUnit.Name
</option>
}
</select>
Selected unit price: {{pricePerUnit | currency}}
Where I have productUnit.Id as value, but productUnit.Price as ng-true-value.
However when I try to submit, instead of the selected value, the price is getting submitted instead of the selected id.
Is there a way in angular to use the price for calculation yet submit an id as value? Maybe something like this:
<option ng-submit-value="@productUnit.Id" ng-true-value="@productUnit.Price">
@productUnit.Name
</option>