Solution: Calculator



examples/angular/calculator.html
<script src= "angular.min.js"></script>
<script src= "calculator.js"></script>

<div ng-app="CalculatorApp" ng-controller="CalculatorController">
  <p><input type="number" ng-model="a"></p>
  <p><input type="number" ng-model="b"></p>
  <p><select ng-model="operator">
        <option>+</option>
        <option>*</option>
        <option>-</option>
        <option>/</option>
     </select></p>
  <p>{{ result() }}</p>
 </div>

examples/angular/calculator.js
angular.module('CalculatorApp', [])
    .controller('CalculatorController', ['$scope', function($scope) {
        $scope.result = function() {
            if ($scope.operator === '+') {
                return $scope.a + $scope.b;
            }
            if ($scope.operator === '-') {
                return $scope.a - $scope.b;
            }
            if ($scope.operator === '*') {
                return $scope.a * $scope.b;
            }
            if ($scope.operator === '/') {
                return $scope.a / $scope.b;
            }
        };
    }]);