-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
27 lines (19 loc) · 790 Bytes
/
app.js
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
angular.module('inspiration', ['angular-kudos', 'firebase'])
.value('fbURL', 'https://angular-kudos.firebaseio.com/')
.factory('Quotes', function($firebase, fbURL) {
return $firebase(new Firebase(fbURL));
})
.controller('MainCtrl', ['$scope','Quotes','$firebase', 'fbURL',
function($scope, Quotes, $firebase, fbUrl){
$scope.quotes = Quotes;
$scope.addCount = function(id){
var keys = $scope.quotes.$getIndex();
keys.forEach(function(key, i) {
if($scope.quotes[key].id == id){
var ref = $firebase(new Firebase(fbUrl + i + "/kudos"));
var oldCount = $scope.quotes[key].kudos;
ref.$set(oldCount + 1);
};
});
}
}])