Created
December 18, 2015 18:53
-
-
Save anonymous/4fc9424750ce6a3b592c to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/futehi
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> | |
<head> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body ng-app="app"> | |
<div ng-controller="SumController"> | |
<select ng-model="value" ng-options="n for n in [1, 2, 3, 4, 5]"></select> | |
<button ng-click="add()">Add</button> | |
The sum of {{ values }} is {{ sum }} | |
</div> | |
<script id="jsbin-javascript"> | |
angular | |
.module('app', []) | |
.controller('SumController', function($scope) { | |
$scope.values = [1, 2]; | |
$scope.add = function() { | |
$scope.values.push(parseInt($scope.value)); | |
}; | |
$scope.$watch('values', function() { | |
$scope.sum = $scope.values.reduce(function(a, b) { | |
return a + b; | |
}); | |
}, true); | |
}); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">angular | |
.module('app', []) | |
.controller('SumController', function($scope) { | |
$scope.values = [1, 2]; | |
$scope.add = function() { | |
$scope.values.push(parseInt($scope.value)); | |
}; | |
$scope.$watch('values', function() { | |
$scope.sum = $scope.values.reduce(function(a, b) { | |
return a + b; | |
}); | |
}, true); | |
});</script></body> | |
</html> |
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
angular | |
.module('app', []) | |
.controller('SumController', function($scope) { | |
$scope.values = [1, 2]; | |
$scope.add = function() { | |
$scope.values.push(parseInt($scope.value)); | |
}; | |
$scope.$watch('values', function() { | |
$scope.sum = $scope.values.reduce(function(a, b) { | |
return a + b; | |
}); | |
}, true); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment