Created
January 10, 2016 01:26
-
-
Save leosilvadev/8b2c2cdbd4fc162b3d5e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<DOCTYPE html> | |
<html ng-app="contador"> | |
<head></head> | |
<body> | |
<section ng-controller="ContadorController"> | |
<input ng-model="numero1" type="number" ng-change="calcula()"> | |
<input ng-model="numero2" type="number" ng-change="calcula()"> | |
<select ng-model="operacao" ng-options="op for op in operacoesDisponiveis" ng-change="calcula()"> | |
</select> | |
<span>{{resultado}}</span> | |
</section> | |
<script src="angular.min.js"></script> | |
<script> | |
angular.module('contador', []); | |
angular.module('contador').controller('ContadorController', function($scope){ | |
$scope.numero1 = 0; | |
$scope.numero2 = 0; | |
$scope.operacao = '+'; | |
$scope.operacoesDisponiveis = ['+', '-', '*', '/']; | |
$scope.calcula = function(){ | |
$scope.resultado = eval($scope.numero1 + $scope.operacao + $scope.numero2); | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment