【问题标题】:Firebase not return anything on angularjsFirebase 不会在 angularjs 上返回任何内容
【发布时间】:2016-12-12 11:57:41
【问题描述】:

我试图从我的 firebase 帐户中获取数据

var myApp = angular.module('myApp',['firebase']);

//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});

myApp.factory("Items", function($firebaseArray) {
  var itemsRef = new Firebase("https://tukang-urut-dayang.firebaseio.com/senarai_pelanggan");
  return $firebaseArray(itemsRef);
})
function MyCtrl($scope,Items) {
   $scope.items = Items;

}

不幸的是,Items 的返回根本没有给出任何输出。我错过了什么吗?

我只是按照本教程进行操作

https://www.firebase.com/docs/web/libraries/ionic/guide.html#section-list-view


Fiddle

【问题讨论】:

  • 您是否按照教程中的身份验证说明进行操作?
  • 影响回泥吗?

标签: angularjs firebase firebase-realtime-database


【解决方案1】:

您正在使用一些不兼容的库版本。

我更新了你的 jsfiddle 以使用这些包括:

https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js
https://cdn.firebase.com/js/client/2.4.0/firebase.js
https://cdn.firebase.com/libs/angularfire/1.2.0/angularfire.min.js

并将控制器定义更新为:

var myApp = angular.module('myApp',['firebase']);

myApp.factory("Items", function($firebaseArray) {
  var itemsRef = new Firebase("https://tukang-urut-dayang.firebaseio.com/senarai_pelanggan");
  return $firebaseArray(itemsRef);
})
myApp.controller("MyCtrl", function ($scope,Items) {
   $scope.items = Items;
});

有了这些改变,它就可以工作了。

查看更新的小提琴:http://jsfiddle.net/puf/puap07ar/3/

【讨论】:

  • 感谢您的回答。这个版本的具体文档在哪里?
猜你喜欢
  • 2018-07-09
  • 1970-01-01
  • 2021-04-24
  • 2017-06-23
  • 1970-01-01
  • 2020-04-15
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多