I am having an issue where the first console.log()
is not returning the correct value, but the second one is. Can anyone provide assistance with this problem?
angular.module('resultsApp', ['ngCookies'])
.config(['$qProvider', function ($qProvider) {
$qProvider.errorOnUnhandledRejections(false);
}])
.controller('resultsController', function($scope) {
var code = localStorage.getItem('code');
$scope.data = "";
var dataRef = firebase.database().ref("0/"+code);
dataRef.on('value', function(snapshot){
console.log(snapshot.val());
$scope.data = snapshot.val();
});
console.log($scope.data)
});