我有一个奇怪的问题,我可以绑定到视图上的选项更改但是当我控制台记录更改的变量的值时,它仍然没有改变。
这是一个非常基本的代码示例
控制器
angular.module('instabugApp')
.controller('SdkIndexCtrl', function ($scope) {
$scope.gradleOptions = [
{ id: 1, name: '14+' },
{ id: 2, name: 'Less than 14' },
{ id: 3, name: 'Less than 14 (Actionbar Sherlock)' }
];
$scope.gradleChoice = $scope.gradleOptions[0];
$scope.gradleChange = function() {
console.log($scope.gradleChoice);
};
$scope.awesomeThings = [
'HTML5 Boilerplate',
'AngularJS',
'Karma'
];
});
HTML
<div class="columns large-6">
{{gradleChoice.name}}
<select ng-model="gradleChoice" ng-change="gradleChange()" ng-options="item as item.name for item in gradleOptions"></select>
</div>