I have the following code:

```
angular.module("MyApp", ['textAngular'])
.controller("demoController", function demoController($scope) {
    $scope.content = null;
    firebase.database().ref('pages/home').on('value', function(snapshot) { $scope.content = snapshot.val(); });
    console.log($scope.content);
});

```

As you can see, all I am trying to do is change a variable in the scope of my controller within a function that accesses the firebase database, in order to store the contents of a certain entry. When attempting this however, the variable simply does not change. I have tried the same thing using 'window.content', as well as trying to use 'var content;' to no avail. Is there any way to allow a variable to be globally accessed from within a function?

edit - When I run the firebase.databse().ref fucntion and use alert(snapshot.val()); it works and the information is displayed in the alert.