I am using ng-options
on a <select>
like this ng-options="item.model for item in prodataSelect | unique:'model' "
But I would like the <value=""
tag of the generated options to contain the item.id
instead of the autoincremental value use by ng-options.
How to achieve this ?
HTML:
<select id = "chosenmodel" class="button button-full button-dark" ng-model="selectedModel" ng-options="item.model for item in prodataSelect | unique:'model' ">
<option value="">Select a Model</option>
</select>
<a id="submitbutton" class="button button-block button-dark ui-btn ui-btn-b ui-corner-all" ng-click='launchCompute()' href="#/app/compute/result">Compute my board</a>
Each item in prodataSelect
is an object :
{
brand: "John",
fun: "0",
id: 1
},
{
brand: "you",
fun: "0",
id: 185
},
{
brand: "Ark",
fun: "0",
id: 17
},
use below syntax
read more about it here
Use "track by item.id" to set option value to id
ng-options="item.id as item.model for item in prodataSelect track by item.id"