我有一个表单,其中包含一个文本输入框和一个按钮。我想要捕获用户在文本输入框中按下回车键的动作-不是为了提交表单,而是为了触发另一个操作。该按钮有其自己独立的单击处理程序,但因某种原因,当我在文本字段中按回车键时它被触发。示例:http://jsfiddle.net/T8zLq/1/
为什么会发生这种情况?
<form onsubmit="return false" ng-submit="mysubmit()" ng-controller="TestCtrl" ng-app="Test">
<input type="text" />
<button ng-click="test()">X</button>
</form>
var app=angular.module("Test", []);
app.controller("TestCtrl", ["$scope", function($scope) {
$scope.test = function() {alert('lol'); };
$scope.mysubmit = function() {alert('submit');};
}]);
为什么会发生这种情况?