Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$id or not $id in the snapshot #326

Closed
albertosantini opened this issue Jun 27, 2014 · 1 comment
Closed

$id or not $id in the snapshot #326

albertosantini opened this issue Jun 27, 2014 · 1 comment

Comments

@albertosantini
Copy link

With the following stack

    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.13/angular.min.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.13/angular-route.min.js"></script>
    <script src="//cdn.firebase.com/js/client/1.0.17/firebase.js"></script>
    <script src="//cdn.firebase.com/js/simple-login/1.6.1/firebase-simple-login.js"></script>
    <script src="//cdn.firebase.com/libs/angularfire/0.7.1/angularfire.min.js"></script>

I noticed the presence of the $id property in the snapshot value, using AngularJS 1.3.0-beta13. Reverting to 1.3.0-beta10, the snapshot contains only the dictionary of the reference.

$firebase(myRef).$on("loaded", function (value) {
    // value contains $id with angular 1.3 beta 13, but not with beta 10.
});

Usually I convert the dictionary in array using angular.forEach and the presence of that property "breaks" the loop.

            angular.forEach(cart, function (item) {
                if (item !== "cart") { // workaround for $id === "cart"
                    myCart.push(item);
                    total += item.qty * item.price;
                }
            });

I don't know if it is a glitch in angularFire or in AngularJS and how I should handle my use case.

@katowulf
Copy link
Contributor

This is a dup of #320; corrected in 0.8. Thanks for the note!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants