Thanks, but I still don't understand something,
It works if I fetch the data with loaded() on the *controller* :

var ref = new Firebase(FIREBASE_URL + 'posts');
var posts = $firebase(ref).$asObject();

posts.$loaded().then(function(){
     $scope.post = posts.$getRecord($routeParams.postid);
});

but when I try to implement it on the find function in the *factory* like
this:
find: function(postId) {
   posts.$loaded().then(function () {
       console.log(posts.$getRecord(postId));
       return posts.$getRecord(postId);
   });
}

and use it instead the above example, in the controller:
$scope.post = Post.find(postid);

it logs the right post, but it returns undefined, why that happens and what
is the correct way to implement this?
I guess it takes some time to fetch the data, so is there another way to do
this in the factory?

Thanks!
On Thursday, August 7, 2014 8:45:51 PM UTC+3, Michael Kato Wulf wrote:

Hey Dor,

Try posts.$getRecord(postId) inside your find function. Since the data is
already in the array and synchronized, there is no reason to create a
duplicate synchronized instance.


On Thu, Aug 7, 2014 at 4:08 AM, Dor Cohen <dor...@gmail.com <javascript:>>
wrote:
Hey, recently I noticed angularfire removed the method child().

I would like to know what is to correct way to handle child nodes:

var ref = new Firebase(FIREBASE_URL + 'posts');
var posts = $firebase(ref);

var Posts = {
create: function(foo) {
return posts.$push({some: foo});
},
find: function(postId) {
// no child method so I need another ref?
var postref = new Firebase(FIREBASE_URL + 'posts/' + postId)
return $firebase(postref);
}
}

also, if I want to add multiple number of child nodes

e.g posts/postId/comments/...

is the only way to do this with $set ?

Thanks alot,
Dor

--
You received this message because you are subscribed to the Google Groups
"Firebase + AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to firebase-angul...@googlegroups.com <javascript:>.
To post to this group, send email to firebase...@googlegroups.com
<javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/firebase-angular/e54f3ee8-90be-4c20-b5f5-c9c52a54e999%40googlegroups.com
<https://groups.google.com/d/msgid/firebase-angular/e54f3ee8-90be-4c20-b5f5-c9c52a54e999%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Firebase + AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-angular+unsubscribe@googlegroups.com.
To post to this group, send email to firebase-angular@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-angular/1688622f-aef4-4f05-b896-0fabac6aa9cc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 of 4 | next ›
Discussion Overview
groupfirebase-angular @
postedAug 7, '14 at 3:43p
activeAug 8, '14 at 8:18p
posts4
users2

2 users in discussion

Dor Cohen: 2 posts Michael Wulf: 2 posts

People

Translate

site design / logo © 2021 Grokbase