AngularFire包含$ firebaseArray或$ firebaseObject错误

时间:2016-04-15 06:38:27

标签: javascript angularjs firebase

有谁知道为什么这么简单的代码会给我一个错误?当我包含$ firebaseObject时,我发出同样的错误:/

angular.js:11383错误:[$ injector:unpr] http://errors.angularjs.org/1.3.2/ $ injector / unpr?p0 = NaNirebaseArrayProvider%20%3C-%20%24firebaseArray%20%3C-%20SinglePageService

错误:$ injector:unpr 未知的提供商 未知提供商:

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


myApp.factory("SinglePageService", ["$firebaseArray", function($firebaseArray) {
    var ref = new Firebase('https://burning-heat-bbbb.firebaseio.com/users/');
    var items = $firebaseArray(ref);

    return {
        all: items,
        get: function (id) {
            console.log("service ID", id);
            var user = items.$getRecord(id);
            console.log(user);
            return user;
        }
    }
}]);



myApp.controller('SinglePage', function SinglePage($scope, SinglePageService, $location, $route) {

    var userId = $route.current.params.id;
    $scope.user = SinglePageService.get(userId);

    console.log("$scope.user", $scope.user);
});



    <script src="https://cdn.firebase.com/js/client/2.0.4/firebase.js"></script>
    <!-- AngularFire -->
    <script src="https://cdn.firebase.com/libs/angularfire/0.9.0/angularfire.min.js"></script>

0 个答案:

没有答案