sid
sid

Reputation: 1116

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

I am getting above error In spite of defining my service name to all necessarily palaces.

here is my 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();
			}
		} ]);

My 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>

Here is my RequestsSerice.js :-

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

I would like to tell you that initially every thing was working fine but after updating cordova to latest version my app stops functioning.

I have checked the spellings too , but still getting the above error while running the code.

Upvotes: 0

Views: 450

Answers (2)

Yerken
Yerken

Reputation: 1942

You cannot use RequestsService at config stage of your angular app. What is the use case for this? More information would be helpful

Upvotes: 1

Anik Islam Abhi
Anik Islam Abhi

Reputation: 25352

Put

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

before

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

Like this

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

Upvotes: 1

Related Questions