I just started learning angularjs, and run into this problem. The above error occurs when I run the application. My codes are as follows
app.js
'use strict';
angular.module('underscore', []).factory('_', function () {
return window._;
});
var myApp = angular.module('myApp', [
'ngRoute']);
myApp.config(function ($routeProvider) {
$routeProvider
.when('/a',
{
controller: 'aController',
templateUrl: 'module/a/a.html'
})
.otherwise({redirectTo: '/view1'});
});
a.js (controller)
'use strict';
myApp.controller('aController',
function($scope,aCollection, $location) {
$scope.foo= {
};
$scope.create= function() {
aCollection.create($scope.foo);
$location.path('/a-creation');
};
});
aCollection.js (service)
'use strict';
myApp.factory('aCollection', function($resource) {
return $resource('../api/dummy', {}, {
create : {method: 'POST' }
})
});
The error is:
Error: [$injector:unpr] http://errors.angularjs.org/1.3.16/$injector/unpr?p0=%24resourceProvider%20%3C-%20%24resource%20%3C-%20aCollection
at Error (native)
at http://localhost:9080/lib/angular.min.js:6:417
at http://localhost:9080/lib/angular.min.js:38:7
at Object.d [as get] (http://localhost:9080/lib/angular.min.js:36:13)
at http://localhost:9080/lib/angular.min.js:38:81
at d (http://localhost:9080/lib/angular.min.js:36:13)
at Object.e [as invoke] (http://localhost:9080/lib/angular.min.js:36:283)
at Object.$get (http://localhost:9080/lib/angular.min.js:34:268)
at Object.e [as invoke] (http://localhost:9080/lib/angular.min.js:36:315)
at http://localhost:9080/lib/angular.min.js:38:110 <div data-ng-view="" class="ng-scope">
Can someone help me out with this?? Many Thanks!!!
Can you try this one?
EDITED