你会这么善良并帮助我修改下面的功能并设置' setInterval'该函数每5秒执行一次?
提前致谢!
$scope.updateIndividual = function () {
console.log('Updating individual', $scope.user.individual);
$scope.user.individual.professionalExperience = experiences;
$scope.user.individual.trainings = trainings;
$scope.user.individual.education = education;
$http({
url: '/individual/update-individual',
method: 'POST',
data: {
individual: $scope.user.individual
}
}).success(function (data) {
if (data.success == true) {
$scope.userConfirm = "Changes Saved Successfully";
$timeout(function () {
$scope.userConfirm = "";
}, 3000);
} else {
$scope.userConfirm = "Something went wrong, please try again";
}
});
}
答案 0 :(得分:2)
将$interval
注入控制器并使用它每5秒运行一次该函数,如下所示:
app.controller('myCtrl', function($scope, $interval) {
$scope.updateIndividual = function() {...};
$interval($scope.updateIndividual, 5000);
});