AngularJS | HTML DOM

ng-show and ng-hide Directive:
Both directives use to show or hide the element of HTML. It is depend upon the value of directives. Values are either “true” or “false”.

Example-1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
<script src=
  </script>
  
<body>
    <center>
        <div ng-app="">
            <!-- ng-show =true -->
            <h1 style="color:green" ng-show="true">
              GeeksforGeeks</h1>
            
            <!-- ng-show =false -->
            <p ng-show="false">GeeksforGeeks</p>
            
            <!-- ng-hide =true -->
            <p ng-hide="true">ng-hide is true</p>
            
            <!-- ng-hide =false -->
            <p ng-hide="false">
              A Computer Science Portal For Geeks</p>
        </div>
    </center>
</body>
  
</html>

chevron_right


Output:

ng-disabled Directives:
It disables the attribute of HTML elements. It binds the data to disabled HTML element’s attributes.
Example-2:



filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
<script src=
  </script>
  
<body>
    <center>
        <h1 style="color:green">GeeksforGeeks</h1>
        <div ng-app="" ng-init="mySwitch=true">
            <p>
                <button ng-disabled="mySwitch" 
                        onclick="alert('Not Disabled')">
                  Click Me!
              </button>
            </p>
            <p>
                <input type="checkbox" 
                       ng-model="mySwitch"/>
              Button
            </p>
            <p>
                {{ mySwitch }}
            </p>
        </div>
    </center>
</body>
  
</html>

chevron_right


Output:



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.