Reputation: 19118
Why doesn't it work to set the $scope.blured
within this setTimeout()
(simulating a post and response)?
$scope.bluryLines = function(value) {
$scope.blured = true;
if (value === '' || value === undefined) {
console.log('value is empty');
} else {
console.log(value);
}
//faking a post
setTimeout(function() {
$scope.blured = false;
console.log('log');
}, 1000);
};
pushing the button cleares it right away.
$scope.removeOverlay = function() {
$scope.blured = false;
};
Upvotes: 1
Views: 145
Reputation: 18905
setTimeout
doesn't run a digest. Use the angular $timeout
service instead.
app.controller('MainCtrl', function($scope, $timeout) {
$scope.bluryLines = function(value) {
$scope.blured = true;
//faking a post
$timeout(function() {
$scope.blured = false;
}, 1000);
};
});
Upvotes: 2