【发布时间】:2015-10-11 11:41:34
【问题描述】:
我有一个选择输入和一个在所选值更改时调用的函数。当我使用键盘箭头键更改值时,模型不会更新(第一次)。 有人可以告诉我为什么吗?
JS:
var app = angular.module('myApp',[]);
function mainController($scope) {
$scope.people = [
{
id: 1,
name: 'Julius'
},
{
id: 2,
name: 'Julius Rock'
},
{
id: 3,
name: 'Christopher'
}
];
$scope.selectionChanged = function() {
console.log('test');
};
}
app.controller('mainController', mainController);
HTML:
<div ng-controller="mainController">
<!-- If you change the value with the arrows ng-change doesn't work on the first change. -->
<select ng-model="selected" ng-options="person.name for person in people track by person.id" ng-change="selectionChanged()"></select>
<span>{{selected}}</span>
</div>
提前致谢。
【问题讨论】:
-
在这里工作正常.. 在 mozila 中,您必须按 Enter 才能进行更改,否则就可以了
-
我正在使用最新的 chrome。在 Edge 中它可以完美运行。在 Firefox 中,我需要按 Enter,就像你说的那样。
标签: javascript html angularjs angularjs-directive