Overview
In this article, we will see ng-hide and ng-show elements in AngularJS. ng-Hide and ng-Show directives are used to control the visibility of the HTML elements. Let's see with an example.
For more articles on AngularJS, kindly refer to.
- Overview Of AngularJS
- Modules And Controller In AngularJS
- Controllers in AngularJS
- AngularJS ng src Directive
- AngularJS ng-Repeat Directive
- Handling Events In AngularJS
- How To Use Two-Way Data Binding In AngularJS
- Filters In AngularJS
Introduction
As I said earlier, ng-Hide and ng-Show directives are used to control the visibility of the HTML elements.
Let's switch back to our Controller,
This is our controller function.
var mypartone = angular.module("mymodule", []).controller("myController", function($scope) {
var employees = [
{
name: "Akshay",
gender: 1,
dateOfBirth: new Date("July 21, 1960"),
Address: "Mumbai",
Salary: "1234.34"
},
{
name: "Milind",
gender: 2,
dateOfBirth: new Date("July 20, 1960"),
Address: "Nashik",
Salary: "12.34"
},
{
name: "Raghvan",
gender: 1,
dateOfBirth: new Date("July 19, 1960"),
Address: "Pune",
Salary: "1235.34"
},
{
name: "Hari",
gender: 1,
dateOfBirth: new Date("July 18, 1960"),
Address: "Mumbai",
Salary: "5589.34"
}
];
$scope.employees = employees;
});
Here, we have an employees array and in that, the employees array is attached to the $scope object.
In our View, we are displaying Data.
<table>
<thead>
<tr>
<th>Name</th>
<th>Gender</th>
<th>Date of Birth</th>
<th>Address</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="employee in employees">
<td>{{ employee.name }}</td>
<td>{{ employee.gender }}</td>
<td>{{ employee.dateOfBirth }}</td>
<td>{{ employee.Address }}</td>
<td>{{ employee.Salary }}</td>
</tr>
</tbody>
</table>









mamala kalalaPosted Jul 7, 2018, 11:10 PM
Ng-show can manage show or hide an element in html then why ng-hide is required?
Nigel FernandesPosted Jul 26, 2016, 9:16 PM
Good, can you post how to do show and hide animation in angular js
kalu singh raoPosted Jul 26, 2016, 3:14 PM
Good one