title: Waiting for response from firebase in angularJS
body: <p>I am new to firebase and I am using new console to simply demonstrate saving, retrieving data from firebase real time database. On retrieving the data, I am connecting it to a model to show it on the screen in list format. But the screen doesn't show anything. I want to use promise to wait until I get the data from the firebase database.</p>
  
  <pre><code>app.factory('Authentication', ['$rootScope', function($rootScope) {
  return {
       getUsers: function() {
          firebase.database().ref('/userInfo').on('value', function (snapshot) {
             return snapshot.val();
          });
       }
     }
  }
  </code></pre>
  
  <p>How do I use promise to wait until the data is fetched.</p>
  
  <pre><code>app.controller('myController', function($scope, $rootScope, Authentication) {
     $scope.userData = Authentication.getUsers();
  }
  </code></pre>