Hi there,

brilliant work with this but I'm having a wee issue saving an object. I
create a ref to a specific location within my firebase and I can save a new
object to that location but then I'm stuck changing my onsen view as the
$scope doesn't seem to have the reference to the new object immediately...

My code is thus:

ref = new Firebase(refBase + "/" + $scope.user.uid + "/things/thing");

Then I save a new thing like this:

ref.push(newThing); // newThing is an object

newThing has a number of categories and I add a category like this:

ref.child(id).child("category").push(newCategory); // newCategory is an
object

then I set my view like this:

$scope.mySplitView.setMainPage('detail.html'); // detail.html ng-repeats
categories associated with the thing.

The thing is though - the angular on the detail.html page doesn't see the
newCategory immediately. Is there a promise I can use or can anyone suggest
what I'm doing wrong...?

Any help greatly appreciated!

Cheers,

Dom

--
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/946d4d33-12df-4617-8c02-b16e9eca2dda%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Dominic Myers at Nov 4, 2014 at 11:57 am
    I knew I'd get there in the end... RTM for the win! I kept looking at the
    $watch function and thinking it must be of use in this instance and I was
    right!

    Once I've bound my syncObject to the $scope I add:

    unwatch = syncObject.$watch(function() {
         console.log("Data loaded");
    });

    Then in my showThing function which calls my detail.html view I:

    unwatch();

    Before adding my new category object I add another watch:

    unwatch = syncObject.$watch(function() {
         $scope.showDetail(id)
    });

    This seems to call showDetail with the appropriate ID once the new category
    has been added.

    Yippee!

    While it works a treat I am concerned that it might not be the best way of
    doing it...?

    Cheers,

    Dom

    On Monday, 3 November 2014 15:10:21 UTC, Dominic Myers wrote:
    Hi there,

    brilliant work with this but I'm having a wee issue saving an object. I
    create a ref to a specific location within my firebase and I can save a new
    object to that location but then I'm stuck changing my onsen view as the
    $scope doesn't seem to have the reference to the new object immediately...

    My code is thus:

    ref = new Firebase(refBase + "/" + $scope.user.uid + "/things/thing");

    Then I save a new thing like this:

    ref.push(newThing); // newThing is an object

    newThing has a number of categories and I add a category like this:

    ref.child(id).child("category").push(newCategory); // newCategory is an
    object

    then I set my view like this:

    $scope.mySplitView.setMainPage('detail.html'); // detail.html ng-repeats
    categories associated with the thing.


    The thing is though - the angular on the detail.html page doesn't see the
    newCategory immediately. Is there a promise I can use or can anyone suggest
    what I'm doing wrong...?


    Any help greatly appreciated!

    Cheers,


    Dom

    --
    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/ed8fa1dc-df23-4bf7-a1ab-57c1f108086e%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Dominic Myers at Nov 4, 2014 at 11:57 am
    I knew I'd get there in the end... RTM for the win! I kept looking at the
    $watch function and thinking it must be of use in this instance and I was
    right!

    Once I've bound my syncObject to the $scope I add:

    unwatch = syncObject.$watch(function() {
         console.log("Data loaded");
    });

    Then in my showThing function which calls my detail.html view I:

    unwatch();

    Before adding my new category object I add another watch:

    unwatch = syncObject.$watch(function() {
         $scope.showDetail(id)
    });

    This seems to call showDetail with the appropriate ID once the new category
    has been added.

    Yippee!

    While it works a treat I am concerned that it might not be the best way of
    doing it...?

    Cheers,

    Dom

    --
    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/f6b17c4a-a379-4783-95f7-fcd0d9f404f5%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Michael Wulf at Nov 4, 2014 at 2:52 pm
    Dom,

    This sounds like a lot of unnecessary work. Most likely, this has to do
    with the code in detail.html, which you haven't shared here. If you can
    create a smallish example of what's going on and post it online to look at,
    we can offer some more advice.

    Alternately, just dig into the guide
    <https://www.firebase.com/docs/web/guide/>, which will set you up for
    success. Pay particular attention to structuring data
    <https://www.firebase.com/docs/web/guide/structuring-data.html>, which will
    teach you about solid data structures, and not to nest data just because
    you can--this is a recipe for headaches later.

    Cheers,
    Kato

    On Tue, Nov 4, 2014 at 3:57 AM, Dominic Myers wrote:

    I knew I'd get there in the end... RTM for the win! I kept looking at the
    $watch function and thinking it must be of use in this instance and I was
    right!

    Once I've bound my syncObject to the $scope I add:

    unwatch = syncObject.$watch(function() {
    console.log("Data loaded");
    });

    Then in my showThing function which calls my detail.html view I:

    unwatch();

    Before adding my new category object I add another watch:

    unwatch = syncObject.$watch(function() {
    $scope.showDetail(id)
    });

    This seems to call showDetail with the appropriate ID once the new
    category has been added.

    Yippee!

    While it works a treat I am concerned that it might not be the best way of
    doing it...?

    Cheers,

    Dom

    --
    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/f6b17c4a-a379-4783-95f7-fcd0d9f404f5%40googlegroups.com
    <https://groups.google.com/d/msgid/firebase-angular/f6b17c4a-a379-4783-95f7-fcd0d9f404f5%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/CAFHX4%3Dq7j-5UfLQ2_sHEsgbzW9y-MunZqZ0R_UpsJK-er_4-CQ%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupfirebase-angular @
postedNov 3, '14 at 5:06p
activeNov 4, '14 at 2:52p
posts4
users2

2 users in discussion

Dominic Myers: 3 posts Michael Wulf: 1 post

People

Translate

site design / logo © 2021 Grokbase