Advertisements

Multiplication of two numbers using Angular Js


In this article,we will disscuss multiplication of two numbers using Angular Js.


Angular Js : AngularJS is a JavaScript framework.It was originally developed by Hevery and Adam Abrons.Now it’s maintained by Google.Angular Js is light weight and easy to learn.It is perfect in Single Page Application projects.Angular Js is open source,free of cost and easy to handle.

Solution:

Let’s do some coding part.In the below example the code part contain two html input, First Number and Second Number.

<div ng-app="">
 
 <p>First Number:
<input type="number" ng-model="num1" ng-init="num1=0" />
 </p>
 <p>Second Number:
 <input type="number" ng-model="num2" ng-init="num2=0" />
 </p>
 <p>Sum: {{ num1 * num2 }}</p>
</div>

AngularJS Reference

AngularJS library written in JavaScript. Angular js reference file is given below.

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>

The AngularJS Major Components:

  • ng-app
  • ng-model
  • ng-bind

Important Knowledge :

  • The expressions are written inside the {{ expression }}.
  • ng-model directive help to bind the value in html control.the above solution num1 it contain the first input value.num2 contain the second input value.
  • ng-app directive define the angular js application.
  • The ng-init directive initializes application data.In this solution num1 and num2 assigned “0” or Zero. so we get sum "0" on the runtime in the both html textbox.
  • "*" help to multiple both input value inside the expression {{ num1 * num2 }}.

Output :

Output of the above solution..

Multiplication of two numbers using Angular Js

Multiplication of two numbers using Angular Js

 

 Example :

Jsfiddle Demo : http://jsfiddle.net/rajeeshmenoth/294k52a9/

Published : http://www.c-sharpcorner.com/Blogs/48229/

Advertisements

3 responses

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: