I have this code:
HTML code:
<!DOCTYPE html>
<html ng-app="test">
<head lang="en">
<meta charset="utf-8">
<title>Wtf is that</title>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.5/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
</head>
<body ng-controller="testCtrl">
{{test}}
<br />
<button ng-click="set()">set</button>
<button ng-click="setTimeout()">setTimeout</button>
</body>
</html>
AngularJS code:
var app = angular.module('test', []);
app.controller('testCtrl', function($scope, $timeout) {
$scope.test = false;
$scope.set = function() {
$timeout(function() {
$scope.test = !$scope.test;
}, 1000);
};
$scope.setTimeout = function() {
$('body').slideUp(1000, function () {
$('body').slideDown(1000, function () {
$scope.test = !$scope.test;
console.log($scope.test);
console.log('done');
});
});
};
});
Why $scope variables doesn't change when I changing after the animation ends?
In timeout:
$scope.set = function() {
$timeout(function() {
$scope.test = !$scope.test;
}, 1000);
};
All working ok.