好的,所以我很确定自己缺少明显的东西,但是我没有看到。
我创建了一个小提琴,本来以为输入框失去焦点时会发出警报消息,但它不起作用,我也不知道为什么。
当用户执行以下步骤时,我期望收到警报消息:
但是这些步骤不会显示警告消息。
当然,有人知道我在做什么错...?
这是代码(与小提琴相同):
<div ng-app>
<div ng-controller="MyCtrl">
<form name="myForm">
<input type="text" ng-model="todoText" size="30"
name="myInput" ng-blur="validate(myForm)">
</form>
</div>
</div>
function MyCtrl($scope) {
$scope.validate = function(form) {
alert('blur!');
};
}
它可能是您的angular版本。您的小提琴正在使用,1.0.x
我已将您更新为1.4.x
它,并且工作正常:
<div ng-app='myApp'>
<div ng-controller="MyCtrl">
{{santity}}
<form name="myForm">
<input type="text" ng-model="todoText" size="30"
name="myInput" ng-blur="validate(myForm)">
</form>
</div>
</div>
Java脚本
angular.module('myApp', []);
angular.module('myApp').controller('MyCtrl', MyCtrl);
function MyCtrl($scope) {
$scope.santity = 'Hello';
$scope.validate = function(form) {
alert('blur!');
};
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句