Getting the following message on my angularjs app:
Error: [$injector:unpr] Unknown provider: $resourceProvider <- $resource <- Item
http://errors.angularjs.org/1.3.8/$injector/unpr?p0=%24resourceProvider%20%3C-%20%24resource%20%3C-%20Item
at http://localhost:49717/Scripts/angular.js:63:12
at http://localhost:49717/Scripts/angular.js:3994:19
at Object.getService [as get] (http://localhost:49717/Scripts/angular.js:4141:39)
at http://localhost:49717/Scripts/angular.js:3999:45
at getService (http://localhost:49717/Scripts/angular.js:4141:39)
at Object.invoke (http://localhost:49717/Scripts/angular.js:4173:13)
at Object.enforcedReturnValue [as $get] (http://localhost:49717/Scripts/angular.js:4035:37)
at Object.invoke (http://localhost:49717/Scripts/angular.js:4182:17)
at http://localhost:49717/Scripts/angular.js:4000:37
at getService (http://localhost:49717/Scripts/angular.js:4141:39) <div ng-view="" class="ng-scope">
My app.js
'use strict';
var SalesApp = angular.module('SalesApp', ['ngRoute']).
config(['$routeProvider', function ($routeProvider) {
$routeProvider.
when('/', { controller: ItemCtrl, templateUrl: 'item.html' }).
otherwise({ redirectTo: '/' });
}]);
SalesApp.factory('Item', function ($resource) {
return $resource('/api/Item/:iid', { iid: '@iid' }, { update: { method: 'PUT' } });
});
var ItemCtrl = function ($scope, $location, Item) {
$scope.items = Item.query();
};
Scripts that I load
<script src="Scripts/jquery-1.9.1.js"></script>
<script src="Scripts/angular.js"></script>
<script src="Scripts/angular-resource.js"></script>
<script src="Scripts/app.js"></script>
<script src="Scripts/angular-resource.js"></script>
<script src="Scripts/angular-sanitize.js"></script>
<script src="Scripts/angular-animate.js"></script>
<script src="Scripts/angular-touch.js"></script>
<script src="Scripts/angular-route.js"></script>
Can't figure out what could possibly have gone wrong? For the sake of simplicity I'm keeping the ItemCtrl in the app.js file, don't know how I would do it otherwise?
you need to list it as an dependency as the $resource service doesn’t come bundled with the main Angular script. After including it in your HTML page it can be included like:
var SalesApp = angular.module('SalesApp', ['ngRoute','ngResource']).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With