Angular Calculator
How do I make an angular calculator?
Calculator implemented using Angular JS and flex layout.. What is a angular calculator? How do you make a angular calculator? This script and codes were developed by Mnicpt on 30 July 2022, Saturday.
Angular Calculator - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Angular Calculator</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="app" ng-app> <div id="calculator" ng-controller="CalcCtrl"> <div class="screen"> <div class="expression" ng-model="expression">{{ expression }}</div> <div class="result" ng-model="result">{{ result }}</div> </div> <div class="keys"> <div class="btn clear" ng-click="clear()">C</div> <div class="btn plusminus">+</div> <div class="btn operator" ng-click="operate('/')">/</div> <div class="btn" ng-click="digit('7')">7</div> <div class="btn" ng-click="digit('8')">8</div> <div class="btn" ng-click="digit('9')">9</div> <div class="btn operator" ng-click="operate('*')">x</div> <div class="btn" ng-click="digit('4')">4</div> <div class="btn" ng-click="digit('5')">5</div> <div class="btn" ng-click="digit('6')">6</div> <div class="btn operator" ng-click="operate('-')">-</div> <div class="btn" ng-click="digit('1')">1</div> <div class="btn" ng-click="digit('2')">2</div> <div class="btn" ng-click="digit('3')">3</div> <div class="btn operator" ng-click="operate('+')">+</div> <div class="btn" ng-click="digit('0')">0</div> <div class="btn" ng-click="digit('.')">.</div> <div class="btn equals" ng-click="equals()">=</div> </div> </div>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='https://ajax.googleapis.com/ajax/libs/angularjs/1.2.4/angular.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Angular Calculator - Script Codes CSS Codes
@import url(http://fonts.googleapis.com/css?family=Open+Sans);
* { box-sizing: border-box; font-size: 20px;
}
html { background: #ccc; height: 100%; font-family: 'Open Sans', sans-serif;
}
#calculator { background: #efefef; width: 250px; margin: 20px auto; border: 4px solid orange; border-radius: 8px; box-shadow: 0 0 10px #aaa, inset 0 0 2px #333; padding: 10px;
}
.screen { position: relative; background: -webkit-linear-gradient(top, rgba(30, 87, 153, 0.4) 0%, rgba(41, 137, 216, 0.4) 50%, rgba(32, 124, 202, 0.4) 51%, rgba(125, 185, 232, 0.4) 100%); flex: 1 100%; border: 1px solid #777; height: 45px; border-radius: 2px; margin: 5px; padding: 5px;
}
.expression { position: absolute; top: 5px; right: 8px; font-size: 12px;
}
.result { line-height: 45px; font-size: 28px; float: right;
}
.keys { -ms-box-orient: horizontal; display: -ms-flexbox; display: -moz-flex; display: -webkit-flex; display: flex; -webkit-justify-content: space-around; justify-content: space-around; -webkit-flex-flow: row wrap; flex-flow: row wrap; padding-top: 10px; width: 100%;
}
.btn { background: #fff; -webkit-flex: 1 20%; width: 40px; height: 40px; margin: 5px; cursor: pointer; border-radius: 5px; border: 1px solid #aaa; padding: 10px; text-align: center; line-height: 18px;
}
.btn:hover { background: #ccc;
}
.clear { -webkit-flex: 3 43%;
}
.plusminus { position: relative; padding-top: 7px;
}
.plusminus:after { position: absolute; top: 10px; left: 18px; content: "_";
}
.operator { background: #bbb;
}
.equals { background: orange;
}
.equals:hover { background: darkorange;
}
Angular Calculator - Script Codes JS Codes
function CalcCtrl($scope) { var operationPressed = false, equalsPressed = false; $scope.expression = ""; $scope.result = "0"; $scope.digit = function(num) { if($scope.result === "0" || operationPressed) { $scope.result = num; $scope.expression += $scope.result; } else if(equalsPressed) { $scope.result = num; $scope.expression = $scope.result; } else { $scope.result += num; $scope.expression += num; } operationPressed = false; equalsPressed = false; }; $scope.clear = function() { $scope.result = "0"; $scope.expression = ""; stack = []; operationPressed = false; equalsPressed = false; }; $scope.operate = function(operand) { if(operationPressed) { return; }else if(equalsPressed) { $scope.expression = $scope.result + operand; equalsPressed = false; } else { $scope.expression += operand; } operationPressed = true; }; $scope.equals = function() { var i = 0; $scope.result = $scope.$eval($scope.expression); $scope.expression += "= "; equalsPressed = true; };
};
![Angular Calculator - Script Codes](http://shots.codepen.io/mnicpt/pen/lLgDw-512.jpg)
Developer | Mnicpt |
Username | mnicpt |
Uploaded | July 30, 2022 |
Rating | 3 |
Size | 3,616 Kb |
Views | 42,504 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Apple Playing Cards | 4,618 Kb |
Plain JavaScript Calculator | 3,600 Kb |
Trinary Tree | 2,282 Kb |
First 100 Prime Numbers | 1,615 Kb |
Rotate Image | 1,843 Kb |
Contact Snippet | 1,815 Kb |
Graph Paper Background | 2,517 Kb |
3,268 Kb | |
Model View Sync | 1,733 Kb |
Fading Divider | 1,728 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
CSSOff 2013 Submission | Codewunder | 14,766 Kb |
Testing Portfolio Page | Sideshowli | 3,395 Kb |
Fullscreen Parallax | Bassta | 3,313 Kb |
Subtle site navigation with description | Necks | 3,206 Kb |
Formations | Cantelope | 5,731 Kb |
Falling Down the Rabbit Hole | Rachelnabors | 4,578 Kb |
Prototype Responsive Homepage | Heyitsolivia | 7,677 Kb |
Mostly Fluid | Mccreath | 3,308 Kb |
React Markdown Previewer | C0d0er | 3,190 Kb |
Simple star rating using js and data-uri | TheEnd | 5,795 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!