Jack Wolther Jack Wolther - 8 days ago 6
Javascript Question

Unknown provider: $resouceProvider <- $resouce

I have searched for a little while and wasn't able to trace the problem

I am getting this error:

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


I am loading scripts in this order:

<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 dependencies are as follows:

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;
});

}])

Answer

Try like this, also clear your cache before trying

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

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

}])
Comments