Created
December 18, 2015 21:42
-
-
Save anonymous/7f91a858c603f0c6b7cf to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/xizazu
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="ctrl"> | |
Score: {{ score.points }} | |
<button ng-click="increment()">Increment</button> | |
</div> | |
<script id="jsbin-javascript"> | |
angular | |
.module('app', []) | |
.value('randomScore', function() { | |
return Math.ceil(Math.random() * 10); | |
}) | |
.factory('score', function(randomScore) { | |
return {points: randomScore()}; | |
}) | |
.controller('ctrl', function($scope, score) { | |
$scope.score = score; | |
$scope.increment = function() { | |
$scope.score.points++; | |
}; | |
}); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">angular | |
.module('app', []) | |
.value('randomScore', function() { | |
return Math.ceil(Math.random() * 10); | |
}) | |
.factory('score', function(randomScore) { | |
return {points: randomScore()}; | |
}) | |
.controller('ctrl', function($scope, score) { | |
$scope.score = score; | |
$scope.increment = function() { | |
$scope.score.points++; | |
}; | |
});</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', []) | |
.value('randomScore', function() { | |
return Math.ceil(Math.random() * 10); | |
}) | |
.factory('score', function(randomScore) { | |
return {points: randomScore()}; | |
}) | |
.controller('ctrl', function($scope, score) { | |
$scope.score = score; | |
$scope.increment = function() { | |
$scope.score.points++; | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment