AngularJS The ng-model Directive Examples




AngularJS The ng-model Directive

<!DOCTYPE html>
<html>
   <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js">
   </script>
   <body>
      <div data-ng-app="" data-ng-init="quantity=1;price=6">
         <h2>Cost Calculator</h2>
         Quantity: <input type="number" ng-model="quantity">
         Price: <input type="number" ng-model="price">
         <p><b>Total in dollar:</b> {{quantity * price}}</p>
      </div>
   </body>
</html>

Output