i have list of element when i click in one of them, i fill the template then i copy it to the new DIV, i got an empty template, when i use $scope.$apply()
i got an error.
$scope.tache_list.forEach(element => {
$scope.var1 = element;
$scope.$apply();
$('#div2').append($("#div1").html());
});
i got Error $rootScope:inprog
, what i can do ?
Wrap your $scope.$apply call inside a $timeout function.
$timeout(function(){
$scope.$apply()
});
Reason: Digest cycle will be moved to event loop and execute when the existing cycle completes.