【发布时间】:2013-03-03 06:22:25
【问题描述】:
在这种特殊情况下,当我按下 Enter 时,我必须使用哪些选项才能使这些输入调用函数?
HTML:
<form>
<input type="text" ng-model="name" <!-- Press ENTER and call myFunc --> />
<br />
<input type="text" ng-model="email" <!-- Press ENTER and call myFunc --> />
</form>
// Controller //
.controller('mycontroller', ['$scope',function($scope) {
$scope.name = '';
$scope.email = '';
// Function to be called when pressing ENTER
$scope.myFunc = function() {
alert('Submitted');
};
}])
【问题讨论】:
标签: angularjs forms form-submit keypress enter