I need your help, i have controller like this:
var apps = angular.module('test',['firebase']);
function app(query, $scope) {
$scope.result = query.data('marendra79@yahoo.com')
}
and the factory like this
apps.factory('query', function($firebase) {
FIREBASE_URL = "https://tokolaundry.firebaseio.com/"
var ref = new Firebase(FIREBASE_URL+'laundry');
var laundry = $firebase(ref);
return {
data: function(email) {
var result = null;
var query = $firebase(ref.startAt(email).endAt(email));
query.$on('loaded', function (value) {
if (value != null) {
var key = query.$getIndex()[0];
this.result = key;
console.log(this.result)
}
return result;
});
}
}
});
The question why i still get null value in $scope.result but i get the key in console log. how i can pass the key value to $scope.result in controller? thanks