繁体   English   中英

orderByChild(),limitTo()在我的angularjs项目中不起作用。

[英]orderByChild(), limitTo() not working in my angularjs project.?

我想实现“使用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

您是否包括:

<script src="https://cdn.firebase.com/js/client/2.1.1/firebase.js"></script>

[不再编辑相关内容]如https://www.firebase.com/docs/rest/quickstart.html 中所述,通过将.json附加到URL的末尾,将任何Firebase URL作为REST端点

 var ref = new Firebase("https://dinosaur-facts.firebaseio.com/dinosaurs.json");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM