我收到此错误并尝试了不同的方法,但仍然没有找到任何解决方案。
这是我的代码:
应用程序.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'});
}]);
服务.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');
这是我的控制器:
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;
};
}]);
在控制器中,我无法访问来自我的服务的变量......所以警报消息不起作用,我收到此错误
错误:未知提供者:myservicesProvider <- myservices