i'm new with both Angular & Firebase. I've been trying to create a factory to update my list of stations but the list just won't seem to update.
When i run the factory code firebase.database... in my controller it works fine though.
controller
.controller('DashCtrl', function ($scope,Stations) {
$scope.stations = [];
$scope.stations = Stations.getStations();
})
services
.factory('Stations', function() {
return {
getStations : function(){
firebase.database().ref('stations').once('value',function(snapshot){
console.log(snapshot.val());
return snapshot.val();
})
}
}
})
What am i doing wrong? Isn't the ng-repeat="(key,station) in stations" list supposed to change after the factory returns the new data ?
Also I've been noticing something in a few tutorials. What is the difference between the below 2 inits.
.controller('DashCtrl', function ($scope,Stations) {
$scope.stations = [];
$scope.stations = Stations.getStations();
})
.controller('DashCtrl', [$scope,Stations,function ($scope,Stations) {
$scope.stations = [];
$scope.stations = Stations.getStations();
}])