I'm trying to get the value of a 'select', but it always shows 'undefined'. I would like from the controller, setting the value to 'B' and at the same time get the value of <select>. What am I doing wrong?
<div ng-controller="myCtrl">
<select ng-model="selectedItemvalue" id='selectedItemvalue' ng-change='myfunction()'>
<option ng-repeat="sel in selectables" value="{{sel}}">{{sel}}</option>
</select>
</div>
angular.module('myApp', [])
// controller here
.controller('myCtrl', function($scope) {
$scope.selectables = [
'A','B','C'
];
//$scope.selectedItemvalue = "B";
console.log($scope.selectedItemvalue)
})
I need obtain the value of the select. and then setting the default value 'B'. I need setting the value to 'B' without running ng-change. And I need to get the value of my select, before ng-change.