Angular Arithmetic Operations BODMAS Rule

Angular Arithmetic Operations BODMAS Rule

Today, We want to share with you Angular Arithmetic Operations BODMAS Rule.
In this post we will show you Addition, Subtraction, Multiplication and Division in AngularJs, hear for angularjs Ordering Mathematical Operations, BODMAS we will give you demo and example for implement.
In this post, we will learn about Arithmetic Operations in AngularJs with an example.

AngularJs is a simple and easy lihrary written in JavaScript framework. It is specific developed by own Google all the employee, now yet Google officially all the modules supports it. There are one or many reasons to handle switch into javascrips libs AngularJS predominantly only one hrowser side client side MVC js frameworks, directive list of ng speacil keywords behavior, now very clearly flexibility. In this tutorial I’m going to show how to perform addition, subtraction, multiplication and division instead of some data to my writing hello world program.

READ :  AngularJs Global Constants Set and Get Variables

First of all the, just like in the my first programs Hello User or hello world example, we create a module one type of module and a controller same scropt call to Within the controller we new create a function like as a CTRL name called Add Live Check Numbers attached all the maths to the $scope. In that function we all the take the values number from the two or more input elements and same each to convert them to Live Check Number with plain or angular JavaScript function call. (In order to simple model directive aviod using and undefined value and so we default both number Live Check Numbers to 0.) Then we add math operators the values and assign some add,subtraction and multiplication it to the newly created sum attribute.

READ :  Flowroute Sending SMS API using PHP

The following code shows how to do math in expression.

Simple Example AngularJS Multiplication


angularjs math operators Example




examples/angular/add_Live Check Numbers.html


{{ firstnumber * secondnumber }}




calculating sum of repeated elements in angularjs ng-repeat

Example 1:

In this example we will bind product_Qty, UniPrice to input fields using ng-model, and write
the expression for total price as {{ product_Qty*productPrice }}.
If the value in the input controls change then the value in the expression will
be updated automatically.

Enter Product Qty :
Enter Product Unit Price :

Product Qty : {{product_Qty}}

READ :  Send and Receive WhatsApp messages using PHP Steps

Product Unit Price : {{productPrice}}

Product Total Price : {{product_Qty*productPrice}}

Simple Example 2:

In this example we will calculate the Percentage of Product Amount for a given Product Amount and
percentage using expression {{ enterInputAmt*enterInputper/100 }}.

Enter Product Amount :
Enter Percentage :

{{enterInputper}}% of {{enterInputAmt}} is : {{enterInputAmt*enterInputper/100}}

Example 3:

In this example we will calculate the Square root of a given Live Check Number. by default
Math function is not avialable in $scope object, for that we will define the Math
function in $scope object as $scope.Math = window.Math; and write
the expression for square root as {{ Math.sqrt(productValue) }}.

Enter Live Check Number :

Square root of {{productValue}} is : {{ Math.sqrt(productValue) }}

var liveapp = angular.module(“infinityknowApp”, []);
liveapp.controller(“SampleCntrl”, function ($scope) {
$scope.product_Qty = 5;
$scope.productPrice = 6;
$scope.productValue = 9;
$scope.Math = window.Math;
$scope.enterInputAmt = 62.50;
$scope.enterInputper = 14;



Leave a Reply

Your email address will not be published. Required fields are marked *