答案 0 :(得分:1)
检查
<div ng-controller="myCtrl">
<select ng-model="selectedItemvalue" id='selectedItemvalue' ng-change='myfunction()'>
<option ng-selected="sel==selectedItemvalue" ng-repeat="sel in selectables" value="{{sel}}">{{sel}}</option>
</select>
<p>Selected Value is : {{selectedItemvalue}}</p>
</div>
angular.module('myApp', [])
// controller here
.controller('myCtrl', function($scope) {
$scope.selectables = [
'A','B','C'
];
$scope.selectedItemvalue = "B";
console.log($scope.selectedItemvalue)
})
答案 1 :(得分:0)
嘿我设法解决了执行代码onchange事件所需的问题。所以你已经在ng-change上运行了myfunction()。你只需要将ur $ scope放在该函数中。希望它有所帮助。
$scope.myfunction = function(){
console.log($scope.selectedItemvalue);
}