我想在div中包含html输入元素radio和复选框的div上添加ng-blur(onFocusOut事件)。因为在数组(样本)中持有我的值的ng模型所以我想从div中注意不是从每个输入元素包含div的情况下触发事件。关注div外,我将有$ http服务在服务器上保存模型。
<div ng-app="app">
<div ng-controller="focusCtrl">
<div ng-blur="sentHttp()" style="height:100px;width:100px;background-color:blue;">
<input type="radio" name="radio" ng-model="sample[shrk]" />A
<input type="radio" name="radio" ng-model="sample[shrk]" />b
<input type="checkbox" ng-model="sample[shrk]" />1
<input type="checkbox" ng-model="sample[shrk]" />2
<input type="checkbox" ng-model="sample[shrk]" />3
</div>
</div>
</div>
角控制器
angular.module('app').controller('focusCtrl', ['$scope', function ($scope) {
$scope.sample= {};
$scope.sentHttp = function() {
console.log("I'm called!");
};
}]);
预先感谢。