Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

$id or not $id in the snapshot #326

@albertosantini

Description

@albertosantini

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions