Skip to content

Instantly share code, notes, and snippets.

Created December 18, 2015 21:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/7f91a858c603f0c6b7cf to your computer and use it in GitHub Desktop.
Save anonymous/7f91a858c603f0c6b7cf to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/xizazu
<!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>
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