错误:[$injector:unp]未知提供程序:RequestsServiceProvider<-请求服务htt

Error: [$injector:unpr] Unknown provider: RequestsServiceProvider <- RequestsService http://errors.angularjs.org/1.3.13/

本文关键字:lt RequestsServiceProvider 请求 htt 服务 程序 injector unp 未知 错误      更新时间:2023-09-26

尽管将我的服务名称定义为所有必要的宫殿,但我还是犯了上述错误。

这是我的app.js

var app = angular.module('ionicApp', [ 'ionic', 'ngCordova', 'checklist-model' ])
app.config(function($stateProvider, $urlRouterProvider) {
  });
app.run([
		'$rootScope',
		'ngCart',
		'ngCartItem',
		'store',
		'$window',
		'$ionicPlatform',
		'RequestsService',
		function($rootScope, ngCart, ngCartItem, store, $window,
				$ionicPlatform, RequestsService) {
			$ionicPlatform.ready(function() {
				pushNotification = window.plugins.pushNotification;
				window.onNotification = function(e) {
					console.log('notification received');
					switch (e.event) {
					case 'registered':
						if (e.regid.length > 0) {
							var device_token = e.regid;
							alert(device_token);
							RequestsService.register(device_token).then(
									function(response) {
										alert(JSON.stringify(response));
										alert("register!");
									});
						}
						break;
					case 'message':
						alert('msg received');
						alert(JSON.stringify(e));
						break;
					case 'error':
						alert('error occured');
						break;
					}
				};
				window.errorHandler = function(error) {
					alert('an error occured');
				}
				pushNotification.register(onNotification, errorHandler, {
					'badge' : 'true',
					'sound' : 'true',
					'alert' : 'true',
					'senderID' : 'your sender id',
					'ecb' : 'onNotification'
				});
			});
			$rootScope.$cart = {
				items : []
			};
			if (angular.isObject(store.get('cart'))) {
				ngCart.$restore(store.get('cart'));
			} else {
				ngCart.init();
			}
		} ]);

我的index.html:-

<html ng-app="ionicApp">
<head>
<head>
<meta charset="utf-8">
<meta name="viewport"
	content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title>App-name</title>
<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<script type="text/javascript" charset="utf-8"
	src="js/PushNotification.js"></script>
  
<script src="lib/ionic/js/ionic.bundle.js"></script>
<!-- cordova script (this will be a 404 during development) -->
<script src="lib/ngCordova/dist/ng-cordova.js"></script>
<script src="js/ng-cordova.min.js"></script>
<script src="cordova.js"></script>
<!-- your app's js -->
<script src="js/app.js"></script>
<script src="js/checklist-model.js"></script>
<script src="js/controllers.js"></script>
<script src="js/services.js"></script>
<script src="js/cart.js"></script>
<script src="js/RequestsService.js"></script>
<script src="js/angular-translate.min.js"></script>
</head>
<body ng-controller="MainCtrl">
	<ion-nav-view></ion-nav-view>
</body>
</html>

这是我的请求Erice.js:-

http://piratepad.net/ep/pad/view/ro.B4M$J6oZcip/最新

我想告诉你,最初一切都很好,但在将cordova更新到最新版本后,我的应用程序停止运行。

我也检查了拼写,但在运行代码时仍然出现上述错误。

放入

<script src="js/RequestsService.js"></script>

之前

<script src="js/app.js"></script>

像这个

<script src="js/RequestsService.js"></script>
<script src="js/app.js"></script>

您不能在angular应用程序的配置阶段使用RequestsService。这个用例是什么?更多信息将有助于