From e001beec6cc0714d5cc2e0d3c99cf07d0b5a76bb Mon Sep 17 00:00:00 2001 From: Vivek Skrillex Date: Sat, 16 Nov 2019 21:19:35 +0530 Subject: [PATCH] Added (basic calculator) ng-app module --- ng-app/viv_ng_basic.js | 86 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 ng-app/viv_ng_basic.js diff --git a/ng-app/viv_ng_basic.js b/ng-app/viv_ng_basic.js new file mode 100644 index 0000000..3a4c9dd --- /dev/null +++ b/ng-app/viv_ng_basic.js @@ -0,0 +1,86 @@ + +app.controller('myCtrl', function($scope) { + + $scope.c_value="5"; + + $scope.addOne = function() { + $scope.c_value += "1"; + } + + $scope.clear = function() { + $scope.c_value = ""; + } + $scope.addTwo = function() { + $scope.c_value += "2"; + } + + $scope.addThree = function() { + $scope.c_value += "3"; + } + + $scope.addFour = function() { + $scope.c_value += "4"; + } + + $scope.addFive = function() { + $scope.c_value += "5"; + } + + $scope.addSix = function() { + $scope.c_value += "6"; + } + + $scope.addSeven = function() { + $scope.c_value += "7"; + } + $scope.addEight = function() { + $scope.c_value += "8"; + } + + $scope.addNine = function() { + $scope.c_value += "9"; + } + $scope.addZero = function() { + $scope.c_value += "0"; + } + + $scope.addDecimal = function() { + $scope.c_value += "."; + } + + $scope.addPlus = function() { + $scope.c_value += "+" + } + + $scope.addMinus = function() { + $scope.c_value += "-"; + } + + $scope.addMulti = function() { + $scope.c_value += "*"; + } + + $scope.addDivide = function() { + $scope.c_value += "/"; + } + + $scope.addMod = function() { + $scope.c_value += "%"; + } + + $scope.solveAdd = function() { + $scope.c_value = $scope.$eval($scope.c_value); + } + + $scope.solveSubtract = function() { + $scope.c_value += "0"; + } + + $scope.solveFraction = function() { + $scope.c_value = 1/$scope.$eval($scope.c_value); + } + + + + +}); \ No newline at end of file