未知提供商:$ resouceProvider< - $ resouce

时间:2016-11-27 12:51:28

标签: javascript angularjs angular-resource

我已经搜索了一段时间,但无法追踪问题

我收到此错误:

Unknown provider: $resouceProvider <- $resouce <- apartmentsFactory

我按此顺序加载脚本:

<script src="../node_modules/angular/angular.min.js"></script>
<script src="../node_modules/angular-base64-upload/dist/angular-base64-upload.min.js"></script>
<script src="../node_modules/angular-ui-router/release/angular-ui-router.min.js"></script>
<script src="../node_modules/angular-resource/angular-resource.min.js"></script>
<script src="../node_modules/ng-dialog/js/ngDialog.min.js"></script>
<script src="../node_modules/jquery/dist/jquery.min.js"></script>
<script src="scripts/script.js"></script>
<script src="scripts/app.js"></script>
<script src="scripts/controllers.js"></script>
<script src="scripts/services.js"></script>

app.js依赖关系如下:

angular.module('rieltorApplication', ['naif.base64', 'ui.router', 'ngResource', 'ngDialog'])

services.js

angular.module('rieltorApplication')
.constant("baseURL", "http://localhost:3000/")
.factory('apartmentsFactory', ['$resouce', 'baseURL', function($resource, baseURL){

        return $resource(baseURL + "apartments/:id", null, {
            'update': {
                method: 'PUT'
            }
        });

}])

controllers.js

angular.module('rieltorApplication')
.controller('apartmentsController', ['$scope','ngDialog', 'apartmentsFactory', function($scope, ngDialog, apartmentsFactory){

    //code for the filters button
    $scope.navopen= false;
    $scope.navtracker = function () {
         if($scope.navopen === false)
             $scope.navopen = true;
         else
             $scope.navopen = false;
     }
    //gets app apartments in the data base and sets the view depending on responce 
    $scope.showMenu = false;
    apartmentsFactory.query(
        function (response) {
            $scope.apartments = response;
            $scope.showMenu = true;

        },
        function (response) {
            $scope.message = "Error: " + response.status + " " + response.statusText;
        });

}])

1 个答案:

答案 0 :(得分:1)

尝试这样做,在尝试之前清除缓存

angular.module('rieltorApplication')
.constant("baseURL", "http://localhost:3000/")
.factory('apartmentsFactory', ['$resource', 'baseURL', function($resource, baseURL){

        return $resource(baseURL + "apartments/:id", null, {
            'update': {
                method: 'PUT'
            }
        });

}])