【发布时间】:2015-05-13 08:03:12
【问题描述】:
我想实现 “使用 firebase 查询数据”,其文档在以下链接中提供:“https://www.firebase.com/docs/web/guide/retrieving-data.html”。我开始实现代码如下:
getDetail : function() {
var ref = new Firebase("https://dinosaur-facts.firebaseio.com/dinosaurs");
ref.orderByChild("height").on("child_added", function(snapshot) {
console.log(snapshot.key() + " was " + snapshot.val().height + " meters tall");
})
},
但是,我无法得到结果,实际上产生了错误:
TypeError: ref.orderByChild is not a function
at Object.history.getDetail (history.js:20)
at Scope.$scope.getDetail (history.js:11)
at $parseFunctionCall (angular.js:12332)
at angular-touch.js:472
at Scope.$get.Scope.$eval (angular.js:14383)
at Scope.$get.Scope.$apply (angular.js:14482)
at HTMLButtonElement.<anonymous> (angular-touch.js:471)
at HTMLButtonElement.jQuery.event.dispatch (jquery.js:4430)
at HTMLButtonElement.jQuery.event.add.elemData.handle (jquery.js:4116)
请指导我,我如何使用这些 “使用 firebase 查询数据” 功能,例如 “按指定子键排序”、按键名排序、按值排序、按值排序优先级等
我项目的firebase版本是:firebase: 2.1.X
请帮忙...
谢谢
【问题讨论】:
-
你能在 codepen、plunkr 等上提供你的代码吗?
-
从您对@EmmanuelGleizer 的回答的评论看来,您的问题在于导入/注入 Firebase/AngularFire。请编辑您的问题以提供模块/控制器的最小、完整示例。见stackoverflow.com/help/mcve
标签: angularjs node.js firebase angularfire