使用Polymerfire从Firebase检索数据

使用Polymerfire从Firebase检索数据,firebase,firebase-realtime-database,polymer-1.0,polymerfire,Firebase,Firebase Realtime Database,Polymer 1.0,Polymerfire,我现在从Polymerfire开始,尝试做一个小应用程序,列出一些存储在Firebase上的纸卡数据。我使用了google labs示例中的一些代码来构建应用程序,因此其状态如下: index.html 我尝试将模板上的项目更改为[[branddata]],结果相同 引发错误的polymer-micro.html代码: deserialize: function (value, type) { switch (type) { case Number: value = Number(value);

我现在从Polymerfire开始,尝试做一个小应用程序,列出一些存储在Firebase上的纸卡数据。我使用了google labs示例中的一些代码来构建应用程序,因此其状态如下:

index.html 我尝试将模板上的项目更改为[[branddata]],结果相同

引发错误的polymer-micro.html代码:

deserialize: function (value, type) {
switch (type) {
case Number:
value = Number(value);
break;
case Boolean:
value = value != null;
break;
case Object:
try {
value = JSON.parse(value);
} catch (x) {
}
break;
case Array:
try {
value = JSON.parse(value);
} catch (x) {
value = null;
console.warn('Polymer::Attributes: couldn`t decode Array as JSON');
}
break;
根据Chrome开发工具,JSON.parse的变量值包含{{branddata}}或[[branddata]],具体取决于我在模板上如何定义它

这是我错过的东西

编辑:我在添加dom模块时对beer-list-app.html做了一些更改。现在出现json错误,日志如下所示:

Initializing stored value.
beer-list-app.html:33 BrandData: 
app-storage-behavior.html:350 Got stored value! undefined []
编辑2:我按照getbuckts的建议修改了beer-list-app.html中数据更改函数的代码。我的控制台将新数据记录为空


提前感谢。

您是否已登录该应用程序?在决定查看我的权限之前,我一直有相同的问题。
尝试更改您的权限。

您是否登录到应用程序?在决定查看我的权限之前,我一直有相同的问题。
尝试更改您的权限。

您可以粘贴branddata的内容吗?…取出模板dom repeat,向branddata属性和console.log(this.branddata)添加一个观察者;作为补充说明,我认为您希望使用firebase文档而不是firebase queryI。我已在此处添加了观察者:。我不通过dataChanged函数输入。我刚刚停止了firebase查询的log函数的执行,并执行了console.log(this.data)返回{{brandata}},然后我执行了console.log(this.branddata)并返回未定义的。只需对代码进行一点改进,console log for this.branddata返回[]将notify:true添加到品牌数据属性描述,它应该运行dataChanged函数现在dataChanged函数工作,但console.log(this.branddata)返回空([])您可以粘贴branddata的内容吗……取出模板dom repeat,向branddata属性和console.log(this.branddata)添加观察者;作为补充说明,我认为您希望使用firebase文档而不是firebase queryI。我已在此处添加了观察者:。我不通过dataChanged函数输入。我刚刚停止了firebase查询的log函数的执行,并执行了console.log(this.data)返回{{brandata}},然后我执行了console.log(this.branddata)并返回未定义的。只需对代码进行一点改进,console log for this.branddata返回[]将notify:true添加到品牌数据属性描述,它应该运行dataChanged函数现在dataChanged函数可以工作,但console.log(this.branddata)返回空([])
Initializing stored value.
polymer-micro.html:673 Polymer::Attributes: couldn`t decode Array as JSON
app-storage-behavior.html:350 Got stored value! undefined {{branddata}}
deserialize: function (value, type) {
switch (type) {
case Number:
value = Number(value);
break;
case Boolean:
value = value != null;
break;
case Object:
try {
value = JSON.parse(value);
} catch (x) {
}
break;
case Array:
try {
value = JSON.parse(value);
} catch (x) {
value = null;
console.warn('Polymer::Attributes: couldn`t decode Array as JSON');
}
break;
Initializing stored value.
beer-list-app.html:33 BrandData: 
app-storage-behavior.html:350 Got stored value! undefined []