任何人都可以在这里指出错误。为什么它不起作用?
http://fiddle.jshell.net/T3m8Z/4/
<div ng-app="app">
<div ng-controller="ctrl">
<select ng-change="selectOption();" >
<option value="0" selected="selected">All</option>
<option value="1">Read</option>
<option value="2">Unread</option>
</select>
</div>
</div>
var app = angular.module('app', []);
app.controller('ctrl', function ($scope) {
$scope.selectOption = function () {
debugger;
alert("test");
};
});
答案 0 :(得分:1)
您需要为select选择一个模型:
<div ng-app="app">
<div ng-controller="ctrl">
<select ng-model="action" ng-change="selectOption();" >
<option value="0" selected="selected">All</option>
<option value="1">Read</option>
<option value="2">Unread</option>
</select>
</div>
</div>
现在它完美无缺:)
答案 1 :(得分:1)
请在选择元素中添加ng-model。
<div ng-app="app">
<div ng-controller="ctrl">
<select ng-model="selectOpt" ng-change="selectOption();" >
<option value="0" selected="selected">All</option>
<option value="1">Read</option>
<option value="2">Unread</option>
</select>
</div>
</div>
var app = angular.module('app', []);
app.controller('ctrl', function ($scope) {
$scope.selectOption = function () {
debugger;
alert("test");
};
});