Please if anyone could help me,
I'm having a problem with ngResource, I've been searching for a solution for 2 hours but haven't found anything so I decided to put a question even though there are similar questions about this subject!
I'm using AngularJS version 1.4.7
I've been working with services just fine and then decided to use $resource,
the web service return a list of commercials.
here is app.js :
var myApp = angular.module('btAngApp' , ['ngMessages','ngResource'])
.run(function($rootScope){
$rootScope.endPoint = "http://localhost:8082/serverprject/rest/";
});
the factory :
myApp.factory('commercialFactory', function($rootScope, $resource){
return $resource($rootScope + 'commercial/findall');
});
the controller :
myApp.controller('editComCtrl', function($scope, $filter, $http, commercialFactory) {
$scope.init = function(){
$scope.getAll();
};
$scope.getAll = function(){
$scope.commercials = commercialFactory.query();
}
$scope.init();
I'm using $http and $filter in another code following the controller code above, I didn't copy it here.
I have included all the files above in index.html and downloaded angular-resource.min.js.
I've tried many scenarios but same error (make the controller and factory in the same file, have the code of the factory inside of the controller, ....) if I don't inject ngResource in angular.module I get this error :
Error: [$injector:unpr] http://errors.angularjs.org/1.4.7/$injector/unpr?p0=%24resourceProvider%20%3C-%20%24resource%20%3C-%20editComCtrl
If I do I get this :
Error: [$injector:modulerr] http://errors.angularjs.org/1.4.7/$injector/modulerr?p0=btAngApp&p1=%5B%24inj....