-1

I am using ngResource and $resource instead of $http in my project. When I switched over to $resource, I received an $injector:unpr error when I ran the program. I checked to make sure that everything was spelled right. Additionally, I made sure that I called it in the HTML.

Here is the module:

angular.module('confusionApp', ['ui.router', 'ngResource'])

Here is the service I am trying to use:

angular.module('confusionApp')
  .constant("baseURL","http://localhost:3000/")
  .service('menuService', ['$resource', 'baseURL', function($resource, baseURL) {
     this.getDishes = function() {
        return $resource(baseURL+"dishes/:id", null, {
            'update':{
                method:'PUT'
            }
        });

    };

Here is where I call the function:

angular.module('confusionApp')
  .controller('MenuController', ['$scope', 'menuService', function($scope, menuService) {
        $scope.showMenu = true;
        $scope.message = "Loading ...";
        $scope.dishes = menuService.getDishes().query();

Here is the HTML scripts:

<script src="../bower_components/angular/angular.min.js"></script>
<script src="../bower_components/angular-ui-router/release/angular-ui-router.min.js"></script>
<script src="../bower_components/angular-resource/angular-resource.min.js"></script>

Any help is greatly appreciated.

jack d
  • 9
  • 1
  • 3

1 Answers1

0

I found the problem was not actually with any of the code itself. The version of angular I was using was out of date compared to the version of angular-resource I had installed. I fixed this by deleting the dependency in the bower.json and then I removed the folder from bower_components. Then I redownloaded angular-resource with a specification of the version I wanted.

$ bower install angular-resource#1.4.8
jack d
  • 9
  • 1
  • 3