Ng-Init-5

 

In this example, ng-init directive initialize the value of quantity and price variable which are bind to quantity and price textbox respectively like: ng-init="quantity=10;price=2000" Below textboxes total is shown in bold element by multiplying quantity and price like {{quantity*price}}.

 
 
 
<!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> <div class="container" ng-init="quantity=10;price=2000"> Quantity: <input type="number" ng-model="quantity"><br /> Costs: <input type="number" ng-model="price"><br /> Total= <b>{{quantity*price}}</b> </div> </div> </body> </html>
Output