Angular ngShow and ngHide Directive

Angular ngShow and ngHide Directive

Today, We want to share with you Angular ngShow and ngHide Directive.
In this post we will show you ngShow and ngHide in angularjs with Example, hear for Simple AngularJS ng-show and ng-hide Tutorial with example we will give you demo and example for implement.
In this post, we will learn about Angular ng-show Directive with an example.

Welcome to the In infinityknow.com website! You will Step By Step learn web programming, easy and very fun. This website allmost provides you with a complete web programming tutorial presented in an easy-to-follow manner. Each web programming tutorial has all the practical examples with web programming script and screenshots available.ngShow and ngHide in angularjs with Example

Description

If we want to show used to ng-show or hide used to ng-hide conditionally an element data(and it is subtree) in the DOM(Browser),
in simple,AngularJS gives us the all (show)ng-show data and (hide)ng-hide data directives.
The ng-hide(hide) directive data is simply the opposite directions of ng-show(show).

READ :  Vuejs Custom Filters -date currency array-objects vuejs filter

The AngularJS can provides a set of all directives to set the all CSS styles and other used to view of all the Elements in the Document.

List of conditionally elements used to ng-show and ng-hide

1st : ng-if – In angularjs ng-if , To data add or data remove elements from view the Document check condition.

2nd : ng-class – In angularjs ng-class,To set an expression that could be processed when the content of data gets loaded elements.

3rd : ng-hide – In angularjs ng-hide,To set whether AngularJS could scroll the ViewData when the content of data gets loaded elements.

4th : ng-show – In angularjs ng-show,To set whether AngularJS could scroll the ViewData when the content of data gets loaded elements.

READ :  AngularJS Custom Service Factory with Example

5th : ng-style – In angularjs ng-style,To set whether AngularJS could scroll the ViewData when the content of data gets loaded elements.

Syntax of show and hide html and css using AngularJS

HTML elements (Like <p>,<div>,<ul>,<li>,<table>,etc..)

 <element ng-hide="expression"></element> // for used hide data
 <element ng-show="expression"></element> // for used show data
 
class (Like <p>,<div>,<ul>,<li>,<table>,etc..)

 <element class="ng-hide"></element>
 <element class="ng-show"></element>
 

Learn how to use AngularJS Element Directives to Show Hide and Remove Elements.

<div ng-show="infinityknow">this is a infinityknow.com welcome message happy 2 help you!!</div>   

<div ng-show="!infinityknow">this is a infinityknow.com goodbye message happy 2 help you!!</div>   


<div ng-show="demodata == 'ng_goodby'">this is a ng_goodby message happy 2 help you!!</div> 

<!-- in angularjs used to function condition defined in your javascript controller to evaluate condition if true or false check -->
<div ng-hide="checkevaldatafunc()"></div> 

<a href ng-click="ngExample = !ngExample">Simple Toggle Example-infinityknow.com</a>
<img ng-src="https://infinityknow.com/example.jpg" ng-show="ngExample">

Full Example of ShowHide in AngularJS :

<html>
<head>
    <title>Simple Example : AngularJS Element Directives : Show data and Hide data</title>
</head>
<body>
    <script type="text/javascript" src="yourapplicationfolder/1.3.9/angular.min.js"></script>
    
    <div ng-app="infinityknowApp" ng-controller="showandhidedataCtrl">
        <input type="button" value="Click to Show or Hide DIV" ng-click="dataShowHide()" />
        <br />
        <br />
        <div ng-show = "IsViewData">
		<p>
			Here Angular king has explained with example, 
			how to show or hide data (toggle)P tag HTML data or DIV on Button click to using angular ng-show and angular ng-hide directives data.
			AngularJS both directives ng-show data and ng-hide data are used to show data and hide data all elements.
		</p>
		</div>
    </div>
</body>
<script type="text/javascript">
        var data_app = angular.module('infinityknowApp', [])
        data_app.controller('showandhidedataCtrl', function ($scope) {
            //Now default : This will hide data the DIV by default when load the data.
            $scope.IsViewData = false; //Boolean
            $scope.dataShowHide = function () {
                //If DIV data is visible script true or false data it will be hide tag and vice versa of data.
                $scope.IsViewData = $scope.IsViewData ? false : true;
            }
        });
    </script>
</html>

demo :

http://jsfiddle.net/deathhell/8Yz7S/4/

READ :  Dynamically Set navbar active tab angularjs ngclass

http://jsfiddle.net/raving/hgjrmoru/

http://fiddle.jshell.net/od3n/K9MLk/

Add a Comment

Your email address will not be published. Required fields are marked *