Just started learning angular, but i've been making a website with jQuery and am now starting on some apps which hook up to the same firebase as the website.
The problem I have is that I can't find a way to get a child property and use it in a ref. I am wanting to get the value "example" in the sample below:
users: {
simplelogin:1 {
CurrentGroup : "example"
}
}
What I would normally do with jQuery would be something like:
currentUserRef.on('value', function(snapshot){
currentGroup = snapshot.val().CurrentGroup;
});
var checkCurrentGroup = setInterval (function(){
if ( currentGroup !== undefined ) {
clearInterval(checkCurrentGroup);
var currentGroupUsersRef = new Firebase(FB + "/groupUsers/" + currentGroup);
//Rest of the code for the page/app
}}, 200);
So, how is this done in Angular? My attempt was to copy the example on the firebase guide:
app.factory("Profile", ["$firebase", function($firebase) {
return function(username) {
var userRef = new Firebase(FB + "/users/" + username);
return $firebase(userRef).$asObject();
}
}]);
app.controller("ProfileCtrl", ["$scope", "Profile",
function($scope, Profile) {
console.log("profile = ", Profile(uid));
console.log("profile current group = ", Profile(uid).CurrentGroup);
}
]);
console logs:
profile = d {$$conf: Object, $id: "simplelogin:76", $priority: null, $save: function, $remove: function…}$$conf: Object$id: "simplelogin:76"$priority: nullCurrentGroup: "Big Group"displayName: "Jim"email: "someone@email.com"firstLogin: trueprovider: "password"provider_id: "simplelogin:76"proto: Object
profile current group = undefined
I could select the user object but when I did user.currentGroup
it would be undefined. No idea if i'm on the right track with that.