Skip to content

Instantly share code, notes, and snippets.

@murphysean
Created August 27, 2014 04:10
Show Gist options
  • Save murphysean/b1deac0bbbb866d30b02 to your computer and use it in GitHub Desktop.
Save murphysean/b1deac0bbbb866d30b02 to your computer and use it in GitHub Desktop.
HTML5 Calculator Exercise
<!DOCTYPE HTML>
<html ng-app="calculator">
<head>
<meta charset="UTF-8">
<title>Calculator</title>
<style>
/*TODO Style of the calculator*/
</style>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.19/angular.min.js"></script>
</head>
<body>
<section>
<article ng-controller="CalcController">
<input type="text" ng-model="a"/>
<input type="text" ng-model="b"/>
<button ng-click="add(a,b)">ADD</button>
<p>{{result}}</p>
</article>
</section>
<script>
angular.module('calculator',[]).controller('CalcController',['$scope',function CalcController($scope){
$scope.result = 0;
$scope.add = function onClick(a,b){
//TODO Update the result here by adding a and b
//TODO Be weary of a and b being interpreted as strings
};
}]);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment