【发布时间】:2015-11-15 21:22:23
【问题描述】:
我正在尝试搜索具有 id 的项目,但收到此消息。所有功能都正常工作。执行时出现此错误:
在 Firebase 中使用数组索引存储数据可能会导致意外 行为。看 https://www.firebase.com/docs/web/guide/understanding-data.html#section-arrays-in-firebase 了解更多信息。
我的工厂
.factory('TEST', function ($firebaseArray) {
var ref = new Firebase('https://shark-firebase.firebaseio.com');
return {
all: function(section) {
var data = $firebaseArray(ref.child(section));
return data;
},
get: function(section, id) {
var data = $firebaseArray(ref.child(section).child(id));
return data;
}
};
});
我一起努力:
get: function(section, id) {
var data = $firebaseArray(ref.child(section));
return data.$getRecord(id);
}
和我的控制器:
如果 $stateParams.section = 'posts' 和 $stateParams.id = '0'。
$scope.loadItem = function(){
$scope.item = TEST.get($stateParams.section, $stateParams.id);
};
【问题讨论】:
标签: angularjs firebase angularfire