【发布时间】:2014-07-15 05:33:39
【问题描述】:
我正在用 Angularjs 开发一个应用程序。我在输入类型 = 文本中使用 ng-keypress 事件。在文本中输入值时,我在按键功能中得到了错误的值。例如,如果我第一次输入“1”,我会得到undefined。第二次,输入任何其他值都会给出第一个值
<input ng-model="NodeId_1" type="text" ng-keypress="getValue()"/>
var angularapp = angular.module('nameapp', []);
angularapp.controller('NameCtrl', function ($scope) {
$scope.getValue = function () {
alert($scope.NodeId_1);//Here first time undefined is coming and second what ever we enter first value will come
}
}
)
【问题讨论】:
-
你能把你的一些代码参考贴在这里
-
尝试使用 Angular 热键:chieffancypants.github.io/angular-hotkeys
-
您不需要使用其他库,请参阅下面我的回答,了解您的实施无法正常工作的原因。现场演示等等。
标签: javascript angularjs