How can I hide a div after a certain amount of time?
2 answers
$timeout
can be used to hide div after delay
var app = angular.module('app', []);
app.controller('myController', function($scope, $timeout) {
$scope.sendReport = function() {
$scope.reportSent = true;
$timeout(function() {
$scope.reportSent = false;
}, 2000);
};
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
<div ng-app='app' ng-controller='myController'>
<button ng-click="sendReport()">send report</button>
<div class="sendStatus" ng-if="reportSent">Report Sent</div>
</div>
+4
source to share