var suc=0;
            var failed=0;
            var tot=0;
            var body={};
            var f = (function() {
                for (var i=0; i< $scope.data.length; i++) {
                    (function() {
                        body = {
                            "data": {
                                email:$scope.data[i].mail,
                                firstName:$scope.data[i].name,
                            };
                        tot=tot+1;
                        if ($scope.group)
                            body.group = $scope.group;
                        $http({
                            url: API.toUrl('api/xxxxx/xxxxx'),
                            method: 'POST',
                            data: body
                        }).then(function(response) {
                            if (response.status == 200) {
                                suc = suc + 1;
                            }
                        },
                        function(error) {
                            if (error.status == 400) {
                                failed = failed + 1;
                            }
                        })
                    })(i);
                }
            })();
            console.log("Data: "+tot+" Success: "+suc+" Failed: "+failed);
The vars suc and failed when I show in console its 0 If I show the vars into the loop and in the IF statements works correctly.
Any idea? Thanks
