Ng-If-1

 

In this example last name textbox will be created if ng-if expression evaluates true i.e first name textbox neither be null nor empty. In our example, we have two textboxes one with ng-model="firstName" and second with ng-model="lastName", but there is span outside lastname textbox with ng-if="firstName!=null && firstName!=''" so if there will be any value in first textbox only then the second textbox will be visible.

 
 
 
<!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> First Name <input type="text" ng-model="firstName" /> <span ng-if="firstName!=null && firstName!=''"> Last Name <input type="text" ng-model="lastName" /></span> </div> </body> </html>
Output