How to Hide Div After Some Time in AngularJS?
Sometimes we require to do like hide div or text or any tag after some time using AngularJS. In this example i am going to show you how to do it.
AngularJS have $timeout variable, $timeout variable through we can set specific time after hide. We can easily set time for hide or show. In this simple example you can see how it is works.
Bellow example you can see and run bellow file in your machine.
Example:
<!DOCTYPE html>
<html>
<head>
<title>Angularjs ng-hide div after few seconds</title>
<script src = "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
</head>
<body>
<div ng-app = "mainApp" ng-controller = "myController">
<p ng-hide="isCheck" style="background:red;padding:5px;">{{ myText }}</p>
</div>
<script>
var mainApp = angular.module("mainApp", []);
mainApp.controller('myController', function($scope, $timeout) {
$scope.myText = "This is for example";
$scope.isCheck = false;
$timeout(function () { $scope.isCheck = true; }, 4000);
});
</script>
</body>
</html>
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- AngularJS Drag and Drop Table Rows Example with Demo
- PHP AngularJS Add Remove Input Fields Dynamically Example
- AngularJS Ajax Autocomplete Using Typeahead in PHP Example
- AngularJS Scroll to a Specific Element using Anchorscroll
- AngularJS Convert Comma Separated String to Array Example
- AngularJS Image Upload with Preview Example
- How to Call Function on Page Load in AngularJS?
- AngularJS Tooltip using UI Bootstrap tpls HTML Example
- AngularJS Simple Datepicker Directive Example Tutorial
- How to Change Date Format using Date Filter in AngularJS?
- AngularJS - How to Limit String Length using Filter?
- AngularJS - How to Capitalize the First Letter of Word Example
- How to Remove HTML Tags from String in AngularJS?
- PHP AngularJS CRUD with Search and Pagination Tutorial