I am getting this error and I tried different methods, but still I have not found any solution.
This is my code:
services.js
angular
.module('myApp.services',[])
.service('myservice', function($resource) {
var pendings = $resource('myUrl2', {methode: 'GET', isArray:true});
var items;
var myPo='rawad al bo3bo3';
var quantity;
var barcode;
return {
getItems: function() {
items = $resource('myUrl', {methode: 'GET', isArray:true});
And this is my controllers:
angular
.module('myApp.controllers', [])
.controller('ReceiveCtrl', ['$scope','myservice', function ($scope,myservice) {
html:
<html lang="en" ng-app="myApp">
<head>
<meta charset="utf-8">
<title>My AngularJS App</title>
<!-- <link rel="stylesheet" href="lib/primeUI/prime-ui-0.9.5.css"> -->
</head>
<body>
<ul class="menu">
<li><a href="#/Receive">view1</a></li>
<li><a href="#/Pending">view2</a></li>
</ul>
<div ng-view></div>
</body>
</html>
In the controller I can't access the variable coming from my services... so the alert message won't work and I get this error
Error: Unknown provider: $resourceProvider <- $resource <- myservice
You have to include angular-resource.js
file and load ngResource
module: angular.module('app', ['ngResource'])
For more details check "Installation" section inside the documentation for the $resource
service: http://docs.angularjs.org/api/ngResource.$resource
The service module also require the resource.
angular.module('myApp.services',[])
should be
angular.module('myApp.services',['ngResource'])
and also the controller needs to know about your service-module
angular.module('myApp.controllers', [])
to
angular.module('myApp.controllers', ['myApp.services','myApp.filters', 'myApp.directives'])
and techincally, your motherModule does not require myApp.services only the myApp.controllers
angular.module('myApp', ['myApp.services','myApp.filters', 'myApp.directives' 'myApp.controllers']).
to
angular.module('myApp', ['myApp.controllers']).
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