Jquery 对div:AngularJS的ng blur进行表单提交或$http调用

Jquery 对div:AngularJS的ng blur进行表单提交或$http调用,jquery,html,angularjs,Jquery,Html,Angularjs,我试图在div中添加ng blur(onFocusOut事件),其中div包含html输入元素radio和checkbox。因为ng模型在数组中保存了我的值(示例),所以我想在焦点从div移出时触发事件,而不是从div包含的每个输入元素中触发事件。在焦点从div移出时,我将有$http服务在服务器上保存模型 <div ng-app="app"> <div ng-controller="focusCtrl"> <div ng-b

我试图在div中添加ng blur(onFocusOut事件),其中div包含html输入元素radio和checkbox。因为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>

提前感谢。

我相信ng blur在内部实现了
onfocusout
事件,而且由于div没有触发
onfocusout
ng blur
在这种情况下不起作用


你需要收听身体上的
点击
事件,检查目标是否不是
div
,然后执行一些,就像有人说div不会触发聚焦/模糊事件一样,但是,使用一个简单的技巧,你可以实现它

解决方案驻留在
选项卡index
属性上。。。

当在div之外单击时,它会工作,但不与选项卡一起工作。。。您需要更多地使用此代码段

函数TestCtrl($scope){
$scope.fields={
“名字”:“朱塞佩”,
“姓氏”:“曼达托”
};
$scope.sendHttp=function(){
log(“字段”,$scope.fields);
};
}
有棱角的
.module('测试',[]))
.controller(“TestCtrl”,[“$scope”,TestCtrl])
;
.test{
填充物:5em 1em;
背景:轻海绿色;
}

angular.module('app').controller('focusCtrl', ['$scope', function ($scope) {
    $scope.sample= {};
    $scope.sentHttp = function() {
        console.log("I'm called!");
        };
}]);