Friday, April 29, 2022

Add Digits of a Number Using ng-bind in AngularJS

 Machine Language

Write a program that uses the ng-bind directive that will accept a series of digits from the user and then the program will add all the digits of a number.  For example, 12345 is equivalent to 15 if we add all the digits of 12345.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.


My mobile number here in the Philippines is 09173084360.


Please subscribe to my channel  https://www.youtube.com/channel/UCOs-lpOoIeJoh6gpJthPoGg


=================================================


Want to support my channel?

GCash Account

Jake Pomperada

09173084360


Paypal

https://paypal.me/jakerpomperada


Patreon

https://www.patreon.com/jakerpomperada


Thank you very much for your support






Program Listing

index.htm

<!-- index.htm
  Author   : Prof. Jake Rodriguez Pomperada, MAED-IT, MIT
  Date     : July 29, 2021 Thursday  9:59 PM
  Place    : Bacolod City, Negros Occidental
  Websites : www.jakerpomperada.com and www.jakerpomperada.blogspot.com
  Email    : jakerpomperada@gmail.com
 -->
<html>
<head>
  <title>Add Digits of a Number Using ng-bind in AngularJS</title>
</head>
<style>
body {
  font-family: arial;
  font-size: 25px;
  font-weight: bold;
}
</style>
<script type="text/javascript" src="angular.min.js">
</script>

<script>
       var app = angular.module("add_digits", []);
        app.controller('app', ['$scope', function ($app) {
         $app.process= function () {
          var num1 = $app.num;
          var sum=0,rem=0;
     
         while(num1)
          {
         rem = num1%10;
         sum = (sum+rem);
         num1 = Math.floor(num1/10);
        }
          $app.result = "The add digits of " + $app.num + " is " + sum + ".";
      }
        }]);
    </script> 
</script>  
<div ng-app="add_digits" ng-controller="app">
  <form>
  <table border="0" cellspacing=10>
  <tr>Add Digits of a Number Using ng-bind in AngularJS</tr>
  <tr>
  <td>Enter a Number </td>
  <td><input type="number"  ng-model="num" ng-change="process()"></td>
  </tr>
   
</table>
  </form>
    <span ng-bind="result"></span>
   </p> 
</div>
</body>
</html>


No comments:

Post a Comment