我正在使用一个由以下内容填充的选择框ng-options
。不幸的是,我无法得到我的ng-change
要调用的函数。
这是我的小提琴 http://jsfiddle.net/MTfRD/1097/
这是我的js
:
var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
$scope.typeOptions = [
{ name: 'Feature', value: 'feature' },
{ name: 'Bug', value: 'bug' },
{ name: 'Enhancement', value: 'enhancement' }
];
$scope.scopeMessage = "default text";
var changeCount = 0;
$scope.onSelectChange = function()
{
changeCount++;
this.message = "Change detected: " + changeCount;
}.bind($scope);
//$scope.form = {type : $scope.typeOptions[0].value};
$scope.form = $scope.typeOptions[0].value;
}
这是我的HTML
:
<div ng-controller="MyCtrl" class="row">
<select ng-model='form' required ng-options='option.value as option.name for option in typeOptions' ng-change="onSelectChange"></select>
<div style="border:1px solid black; width: 100px; height:20px;">{{scopeMessage}}<div>
</div>
目前,这阻碍了我的工作项目,因此我们将不胜感激任何帮助。谢谢!
两件事......都很简单:)
-
ng-change=onSelectChange
应该onSelectChange()
-
this.message
应该this.scopeMessage
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)