I am injecting ngResource in my app's module :
angular.module('confusionApp', ['ui.router', 'ngResource'])
, then injecting $resource dependency in my service :
angular.module('confusionApp')
.constant('baseURL', 'http://localhost:3000/')
.service('menuFactory', ['$resource', 'baseURL', function($resource, baseURL) {
I have also included the script in my index.html file :
<script src="../bower_components/angular/angular.js"></script>
<script src="../bower_components/angular-ui-router/release/angular-ui-router.js"></script>
<script src="../bower_components/angular-resource/angular-resource.js"></script>
<script src="scripts/app.js"></script>
<script src="scripts/controllers.js"></script>
<script src="scripts/services.js"></script>
I am running a json-server on my machine and whenever the $resource is requesting data, the browser's js console cannot identify $resource and shows this error:
Error: [$injector:unpr] Unknown provider: $resourceProvider <- $resource <- menuFactory
Please help or do point towards somewhere which can help!!
Update
my bower.json dependencies:
"dependencies": {
"bootstrap": "~3.3.5",
"font-awesome": "~4.4.0",
"angular": "1.4.x",
"angular-route": "1.4.x",
"angular-resource": "1.4.x",
"angular-ui-router": "~0.2.17"
}
It turns out to be a conflict between versions of angular and angular-resource. I don't know how it got installed, given I had installed it through bower, although I did explicitly mentioned it's version in bower.json, did not let the bower command tool save it while installing. I had to remove the angular-resource from the bower_components and also removed the dependency from bower.json and reinstall angular-resource with the -S flag.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.