Ng-If-7

 

In this example we can show div element whose Id is "my-div" based on value of showDiv variable with ng-model directive which will set the value of checkbox to showDiv variable.If ng-if evaluates showDiv variable value is true then div will show otherwise it will hide.

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Welcome to LearnKode - A code learning platform</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> </head> <body ng-app> <div> <input type="checkbox" ng-model="showDiv" /> <label for="showDiv">Toggle Div</label> <div ng-if="showDiv"> Learn It <b>ng-if Example</b> </div> </div> </body> </html>
Output