-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
40 lines (31 loc) · 1.57 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<!doctype html>
<html ng-app="awesome-voter">
<head>
<link href="css/main.css" rel="stylesheet" type="text/css"/>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.18/angular.min.js"></script>
<script src="https://cdn.firebase.com/js/client/1.0.15/firebase.js" ></script>
<script src="https://cdn.firebase.com/libs/angularfire/0.7.1/angularfire.min.js" ></script>
<script>
angular.module("awesome-voter", ["firebase"])
.controller('VoteController', function($scope, $firebase) {
var yesVotesRef = new Firebase("https://awesome-voter.firebaseio.com/votes/yes");
$firebase(yesVotesRef).$bind($scope, "yesVotes");
var noVotesRef = new Firebase("https://awesome-voter.firebaseio.com/votes/no");
$firebase(noVotesRef).$bind($scope, "noVotes");
$scope.vote = function(data) {
var votesRef = new Firebase("https://awesome-voter.firebaseio.com/votes/"+data);
votesRef.transaction(function(currentVal){
return currentVal+1;
});
}
});
</script>
</head>
<body>
<div class="container-fluid fill" ng-controller="VoteController">
<button class="col-xs-6 btn-success fill" ng-click="vote('yes')"><h1>{{yesVotes}}</h1></button>
<button class="col-xs-6 btn-danger fill" ng-click="vote('no')"><h1>{{noVotes}}</h1></button>
</div>
</body>
</html>