A simple calculator with AngularJS

AngularJs is a javascript based framework to create powerful and dynamic web applications.With the help of AngularJs we can extend the capabilities of HTML and use functions like Data-binding, MVC architecture and much more.

Below is a simple example of a calculator built with AngularJs, I have tried to use as much as minimal code possible.The main functionlity used is data-binding and calling operating functions using directive.

So I have used ng-repeat for the numbers and I have bind a function to them which will pass the value using $index to output function.For the operators I have used a common function as well and I am passing just the operator.

The clear button just resets the output variable to zero.now lets the AngularJs code.

Comments (1)

Rain

– Catch error input when press ‘.’ 2 times per series of numbers.
– Only accept 10 numbers per series of numbers.
– Check if not complete operate.
– User only can do 1 formula per 1 series of numbers.

Still bug, if you can find out the best way please let me know:
– When max 10 numbers, if you press delete, the program still accepts more than 10 numbers?
– Some time after calculation, the program allows to input max 12 numbers?