relating service and controller AngularJS Error: Unknown provider:
myservicesProvider
I am getting this error and I tried different methods, but still I have
not found any solution.
This is my code:
app.js
angular.module('myApp', [ 'myApp.services','myApp.filters',
'myApp.directives',
'myApp.controllers']).
config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/Receive', {templateUrl: 'partials/partial1.html',
controller: 'ReceiveCtrl'});
$routeProvider.when('/Pending', {templateUrl: 'partials/partial2.html',
controller: 'PendingCtrl'});
$routeProvider.when('/ResumePending', {templateUrl:
'partials/partial3.html', controller: 'PendingCtrl'});
$routeProvider.otherwise({redirectTo: '/view1'});
}]);
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});
return items ;
},
setQty: function(qty){
quantity=qty;
},
deletePO : function(id){
},
suspend:function(id){
//URL needed
},
}).
value('version', '0.1');
And this is my controllers:
angular.module('myApp.controllers', []).controller('ReceiveCtrl',
['$scope','myservice', function ($scope,myservice) {
$scope.po='rawad';
alert ('WoW!! It is '+myservice.getPO);
$scope.quantity='';
$scope.barcode='';
$scope.addProduct= function(){
myservice.setQty($scope.quantity);
myservice.setBc($scope.barcode);
myservice.addToPliste;
};
}]);
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: myservicesProvider <- myservices
No comments:
Post a Comment