Nonsense not much to say, directly on the code.
function Myselectctrl ($scope) { $scope. Model = [ { id:10002, maincategory: ' Male ', ProductName: ' Washed T-shirt ', productcolor: ' Black ' }, { id:10004, Maincategory: ' Female ', ProductName: ' V-neck short sleeves ', productcolor: ' Red ' }, { id:10006, Maincategory: ' Male ', ProductName: ' Round neck long sleeves ', productcolor: ' White ' }]; $scope. Selected = 10002;}
<select ng-model= "selected" Ng-options= "M.id as (M.productcolor + '-' + m.productname) for M in model" > <o Ption value= "" >--Choose a try--</option></select>
- It is recommended not to pass resource directly to the API, as long as the string or integer (such as binding is Ng-model= "selected")
- Do not control angular generated by the <option>...</option> value is what, want to pass what values to the back end in Ng-options= "" in the first parameter to write, as this example is M.id
Write down these, I hope I will not be angular the default check and the value of the problem interference!
The best practise of the ng-options of Angularjs