I am using Angularfire for my login system and trying to get current logged in user's username for purpose of using in controller. Firts getting uid
from $getAuth
and sync it with data in database. But what I am trying below is not working.
.factory("Auth", function($firebaseAuth) {
var ref = new Firebase("URL");
return $firebaseAuth(ref);
})
.factory("Konusma", function($firebaseObject) { //When you give user's uid to this factory its gives you user data in database.
return function(xm) {
var ref = new Firebase("URL");
var userdata = ref.child('users').child(xm);
return $firebaseObject(userdata);
}})
.controller("chatCtrl", function(Auth, Konusma) {
var userx = Auth.$getAuth(); //Current logged in user's uid and email
var chatci = function() { //Trying to get current logged in user's username and other data according to uid which is comes from Auth.$getAuth.
Konusma(userx.uid).$loaded().then(function(data){
return data.username;
});
};