AngularJS Tutorial 11:ng-if directive syntax with example


ng-if is useful for displaying the HTML elements as per true or false

Syntax with Example:

<div ng-if="value">

Full example: 

<!DOCTYPE html>
<html>
<head>
    <script src="angular.min.js"></script>
</head>

<body ng-app>
    
    <input type="checkbox" ng-model="value" ng-init="value=true" />
    <br /><br />
    <!-- ng-if is useful for displaying the HTML elements as per true or false-->
    <div ng-if="value">
        Visible if checkbox is checked. <br />
    </div>
    Visible always. 
</body>
</html>




If you have any queries or suggestions, please feel free to ask in comments section.
Share this post :

Post a Comment

Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.

 
Support : Ranga Rajesh Kumar
Copyright © 2012. ASP.NET Examples - All Rights Reserved
Site Designed by Ranga Rajesh Kumar