Firebase.push失败:第一个参数包含无效键($$ hashKey) [英] Firebase.push failed: first argument contains an invalid key ($$hashKey)

查看:165
本文介绍了Firebase.push失败:第一个参数包含无效键($$ hashKey)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我开始学习AngularJS +火力地堡。我想在我的火力点来写这样一个对象:

I recently started learning AngularJS+Firebase. I'm trying to write in my firebase an object like this:

{
    title: "Personal Information",
    say: [
        [{ "eng": "What's", "ukr": "Що є" }, { "eng": "your", "ukr": "твоє" }, { "eng": "surname?", "ukr": "прізвище?" }],
        [{ "eng": "Smith", "ukr": "Сміт" }],
        [{ "eng": "What's", "ukr": "Що є" }, { "eng": "your", "ukr": "твоє" }, { "eng": "first", "ukr": "перше" }, { "eng": "name?", "ukr": "ім'я?(не фамілія)" }]
    ]
}

与行:

lessondata.add($scope.topic);

其中lessondata'是()与angularFireCollection创建的服务和$ scope.topic - 绑定到我UI对象。
但得到了以下错误:
Firebase.push失败:第一个参数包含在财产say.0.0无效键($$ hashKey)。钥匙必须是非空字符串,不能包含。,#,$,/,[或]

我的理解火力地堡不允许使用0,即使它是在一个附加的数组,零关键是自然的一个关键的关键。所以,我要改变我的对象结构,一些硬codeD实例或我错过了什么?在此先感谢!

As I understood Firebase do not allow to use 0 as a key even if it's a key in an attached array for which zero key is natural. So should I change my object structure in some hardcoded instance or I miss something? Thanks in advance!

推荐答案

编辑:阿南特指出了意见,在角(1.0.7 ATM)的最新稳定版本,可以使用 angular.copy(OBJ)删除 $$ hashkey 属性。

As Anant points out in the comments, in the latest stable version of Angular (1.0.7 atm), you can use angular.copy(obj) to remove $$hashkey attributes.

像迈克尔表示,$在'$$ hashKey'是问题。角创建幕后 $$ hashKey 属性(参见更多在这里:<一href=\"https://groups.google.com/forum/#!topic/angular/pI0IgNHKjxw\">https://groups.google.com/forum/#!topic/angular/pI0IgNHKjxw).我做类似 myRef.push解决此问题得到(angular.fromJson(angular.toJson(myAngularObject)))

Like Michael said, the '$' in '$$hashKey' is the issue. Angular creates the $$hashKey properties behind the scenes (see more here: https://groups.google.com/forum/#!topic/angular/pI0IgNHKjxw). I've gotten around this issue by doing something like myRef.push(angular.fromJson(angular.toJson(myAngularObject))).

这篇关于Firebase.push失败:第一个参数包含无效键($$ hashKey)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆