FAQ
I am trying to query the opening orders that is not bid by users yet. After
retrieved & I construct an array & push the result to that array . Then, I
assigned it to the scope variable to show the retrieved result & show on
the screen, but it is failed. It only will show after I tried to move the
sidemenu. I wonder why this happened. Anything I did wrong ? Please


   var ref = new
Firebase("https://crackling-torch-3497.firebaseio.com/OpeningOrders/");
   var orderListRef = new
Firebase("https://crackling-torch-3497.firebaseio.com/UserProfile/simplelogin:82/OrderHistory/Bidded");

   $scope.ordersList = $firebase(ref).$asArray();

   $scope.openingOrdersList = [];

   ref.on('value', function(openingOrdersSnapshot) {
     openingOrdersSnapshot.forEach(function(ordersSnap) {
     var orderID = ordersSnap.key();

       orderListRef.child(orderID).on('value', function(userPathSnapshot) {
         if(userPathSnapshot.val() === null) {

            $scope.openingOrdersList.push({$id: orderID, value:
ordersSnap.val()});

         }
       })

     });


$scope.orders = $scope.openingOrdersList;
   })

--
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/fe22a178-bf9f-40fa-913b-136df3837000%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Jacob Wenger at Mar 8, 2015 at 1:08 am
    Hey there,

    I think you are making this too complex. What is the difference between
    $scope.ordersList and $scope.openingOrdersList? Instead of Firebase's
    push() <https://www.firebase.com/docs/web/api/firebase/push.html> method,
    you should just use $scope.ordersList.$add()
    <https://www.firebase.com/docs/web/libraries/angular/api.html#angularfire-firebasearray-addnewdata>.
    The problem you are running into is that the Angular $digest loop is not
    being run and your view is not being updated. Using $add() should fix that.

    Jacob
    On Fri, Mar 6, 2015 at 2:21 AM, Tsz Hing Lau wrote:

    I am trying to query the opening orders that is not bid by users yet.
    After retrieved & I construct an array & push the result to that array .
    Then, I assigned it to the scope variable to show the retrieved result &
    show on the screen, but it is failed. It only will show after I tried to
    move the sidemenu. I wonder why this happened. Anything I did wrong ? Please


    var ref = new Firebase("
    https://crackling-torch-3497.firebaseio.com/OpeningOrders/");
    var orderListRef = new Firebase("
    https://crackling-torch-3497.firebaseio.com/UserProfile/simplelogin:82/OrderHistory/Bidded
    ");

    $scope.ordersList = $firebase(ref).$asArray();

    $scope.openingOrdersList = [];

    ref.on('value', function(openingOrdersSnapshot) {
    openingOrdersSnapshot.forEach(function(ordersSnap) {
    var orderID = ordersSnap.key();

    orderListRef.child(orderID).on('value', function(userPathSnapshot) {
    if(userPathSnapshot.val() === null) {

    $scope.openingOrdersList.push({$id: orderID, value:
    ordersSnap.val()});

    }
    })

    });


    $scope.orders = $scope.openingOrdersList;
    })

    --
    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/fe22a178-bf9f-40fa-913b-136df3837000%40googlegroups.com
    <https://groups.google.com/d/msgid/firebase-angular/fe22a178-bf9f-40fa-913b-136df3837000%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/CAGcMwsANYbVNtrsrgqfx2cJ3fVzvNcdomZbdwmP5ciXkJrXjig%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.
  • Tsz Hing Lau at Mar 8, 2015 at 1:42 pm
    Hi Jacob,

    Thanks for your help!!

    It is because I only want to show the opening orders that is not submitted
    by the user. If I still use the $scope.orderList to add it to the unbid
    orders , it will sync to the firebase, which means all other users are able
    to read it. We only want to display the opening orders based on their
    bidded records. If they submitted before, we do not show it. Is it the
    above method could solve it ? Thanks!!

    Anson
    On Sunday, 8 March 2015 09:08:23 UTC+8, Jacob Wenger wrote:

    Hey there,

    I think you are making this too complex. What is the difference between
    $scope.ordersList and $scope.openingOrdersList? Instead of Firebase's
    push() <https://www.firebase.com/docs/web/api/firebase/push.html> method,
    you should just use $scope.ordersList.$add()
    <https://www.firebase.com/docs/web/libraries/angular/api.html#angularfire-firebasearray-addnewdata>.
    The problem you are running into is that the Angular $digest loop is not
    being run and your view is not being updated. Using $add() should fix
    that.

    Jacob

    On Fri, Mar 6, 2015 at 2:21 AM, Tsz Hing Lau <lautszh...@gmail.com
    <javascript:>> wrote:
    I am trying to query the opening orders that is not bid by users yet.
    After retrieved & I construct an array & push the result to that array .
    Then, I assigned it to the scope variable to show the retrieved result &
    show on the screen, but it is failed. It only will show after I tried to
    move the sidemenu. I wonder why this happened. Anything I did wrong ? Please


    var ref = new Firebase("
    https://crackling-torch-3497.firebaseio.com/OpeningOrders/");
    var orderListRef = new Firebase("
    https://crackling-torch-3497.firebaseio.com/UserProfile/simplelogin:82/OrderHistory/Bidded
    ");

    $scope.ordersList = $firebase(ref).$asArray();

    $scope.openingOrdersList = [];

    ref.on('value', function(openingOrdersSnapshot) {
    openingOrdersSnapshot.forEach(function(ordersSnap) {
    var orderID = ordersSnap.key();

    orderListRef.child(orderID).on('value', function(userPathSnapshot) {
    if(userPathSnapshot.val() === null) {

    $scope.openingOrdersList.push({$id: orderID, value:
    ordersSnap.val()});

    }
    })

    });


    $scope.orders = $scope.openingOrdersList;
    })

    --
    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/fe22a178-bf9f-40fa-913b-136df3837000%40googlegroups.com
    <https://groups.google.com/d/msgid/firebase-angular/fe22a178-bf9f-40fa-913b-136df3837000%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/042e257f-617e-4a6e-8f45-21462c6e238d%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Jacob Wenger at Mar 10, 2015 at 12:12 am
    Hey Anson,

    I'm not familiar with a lot of the bid / order lingo you are using, so I'm
    not sure I fully understand, but you will probably get more mileage
    out of structuring
    your data using our best practices
    <https://www.firebase.com/docs/web/guide/structuring-data.html>. For
    example, I'd store all items (orders?) in a large list and then for each
    user, I'd store a list of orders for which they have access to. Then, you
    can bind to that list using $firebaseArray and bind to each order
    individually using its ID and $firebaseObject.

    {
       orders: {
         $orderId: {
            ...
         }
       },
       users: {
         $userId: {
           name: <name>,
           ...,
           orders: {
             order1234: true,
             order 6431: true,
             ...
           }
         }
       }
    }

    Jacob
    On Sun, Mar 8, 2015 at 6:42 AM, Tsz Hing Lau wrote:

    Hi Jacob,

    Thanks for your help!!

    It is because I only want to show the opening orders that is not submitted
    by the user. If I still use the $scope.orderList to add it to the unbid
    orders , it will sync to the firebase, which means all other users are able
    to read it. We only want to display the opening orders based on their
    bidded records. If they submitted before, we do not show it. Is it the
    above method could solve it ? Thanks!!

    Anson
    On Sunday, 8 March 2015 09:08:23 UTC+8, Jacob Wenger wrote:

    Hey there,

    I think you are making this too complex. What is the difference between
    $scope.ordersList and $scope.openingOrdersList? Instead of Firebase's
    push() <https://www.firebase.com/docs/web/api/firebase/push.html>
    method, you should just use $scope.ordersList.$add()
    <https://www.firebase.com/docs/web/libraries/angular/api.html#angularfire-firebasearray-addnewdata>.
    The problem you are running into is that the Angular $digest loop is not
    being run and your view is not being updated. Using $add() should fix
    that.

    Jacob

    On Fri, Mar 6, 2015 at 2:21 AM, Tsz Hing Lau <lautszh...@gmail.com>
    wrote:
    I am trying to query the opening orders that is not bid by users yet.
    After retrieved & I construct an array & push the result to that array .
    Then, I assigned it to the scope variable to show the retrieved result &
    show on the screen, but it is failed. It only will show after I tried to
    move the sidemenu. I wonder why this happened. Anything I did wrong ? Please


    var ref = new Firebase("https://crackling-torch-3497.firebaseio.com/
    OpeningOrders/");
    var orderListRef = new Firebase("https://crackling-
    torch-3497.firebaseio.com/UserProfile/simplelogin:82/OrderHistory/Bidded
    ");

    $scope.ordersList = $firebase(ref).$asArray();

    $scope.openingOrdersList = [];

    ref.on('value', function(openingOrdersSnapshot) {
    openingOrdersSnapshot.forEach(function(ordersSnap) {
    var orderID = ordersSnap.key();

    orderListRef.child(orderID).on('value',
    function(userPathSnapshot) {
    if(userPathSnapshot.val() === null) {

    $scope.openingOrdersList.push({$id: orderID, value:
    ordersSnap.val()});

    }
    })

    });


    $scope.orders = $scope.openingOrdersList;
    })

    --
    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.
    To post to this group, send email to firebase...@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/
    msgid/firebase-angular/fe22a178-bf9f-40fa-913b-
    136df3837000%40googlegroups.com
    <https://groups.google.com/d/msgid/firebase-angular/fe22a178-bf9f-40fa-913b-136df3837000%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/042e257f-617e-4a6e-8f45-21462c6e238d%40googlegroups.com
    <https://groups.google.com/d/msgid/firebase-angular/042e257f-617e-4a6e-8f45-21462c6e238d%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/CAGcMwsDW8XhDFxZ5m0309Bd3rzebYagUSDC36zXyyh5ckH_Cog%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupfirebase-angular @
postedMar 8, '15 at 12:40a
activeMar 10, '15 at 12:12a
posts4
users2

2 users in discussion

Jacob Wenger: 2 posts Tsz Hing Lau: 2 posts

People

Translate

site design / logo © 2021 Grokbase