How do i get index value of selected ng-options and how to get the value in the controller?
You can do :
<select ng-model="yourModel" ng-options="item for item in itemList"> </select>
and then use $scope.yourModel as an object, containing your index if set before
do i need to pass anything in my function?? Because i want to obtain index value in the controller
If you have an ng-option, you must have an array of objects, right ?
then you should have objects like this :
var myObject = {
name : “itemName”,
key : “value”,
…
“id” : “itemID”
}
In your select, you can add ng-change=“myFunction(item)”
then in controller you add
$scope.myFunction = function(item){
console.log("Item ID : " + item.id);
}
Is it clear enough ?
yea thank you so much