Issue: [$injector:unpr] Provider not found: RequestsServiceProvider <- RequestsServiceFor more information on this error, please visit the website: http://errors.angularjs.org

Despite defining my service name in all necessary places, I am still encountering the error mentioned above.

Below 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 :

$J6oZcip/latest

I want to mention that everything was functioning properly initially, but after updating Cordova to the latest version, my app stopped working.

I have double-checked the spellings, yet I still encounter the aforementioned error when running the code.

Answer №1

Insert

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

prior to

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

Following this format

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

Answer №2

It is important to note that RequestsService should not be utilized during the configuration phase of your Angular application. Can you provide further details on the specific scenario where this restriction applies?

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Upon my initial click of the delete button, all the notes vanished. However, after refreshing the page, everything was back to normal and functioning properly

After numerous attempts, I have exhausted almost all troubleshooting methods. I meticulously tested my API to rule out any issues related to it. Strangely, the problem only occurs upon initial page visit, but works flawlessly upon refreshing. Prior to cli ...

Video player on website experiencing issues with playing VAST ads

Hey there! Check out this awesome site for Music Videos: (Music Videos(Player)) I've been testing different options, but if you have a better suggestion, please let me know. Any help would be really appreciated. If I can't figure it out on my o ...

Error message "Truffle 'Migrations' - cb is not a valid function"

I created a straightforward smart contract using Solidity 0.6.6 and now I'm attempting to deploy it on the BSC Testnet. Here's what my truffle-config.js file looks like (privateKeys is an array with one entry ['0x + privatekey']): netw ...

Tips for moving an input bar aside to make room for another

Is it feasible to have two input bars next to each other and keep one open until the other is clicked, then the first one closes as well? I attempted using a transition with "autofocus," but the bar ends up closing when clicked on in my site. If anyone ca ...

Vue looping through nested checkbox groups

Here is an object I am working with: rightGroups: [ { name: "Admin Rights", id: 1, rights: [ { caption: 'Manage Rights', name: 'reports', ...

Updating the src of an iframe and adding an onclick event to a link using JavaScript

Looking to design a page that accommodates both login and sign up functionalities by dynamically updating the src of an iframe. In the navigation bar, there is: <li id="change"><a onclick="sign()">Sign up</a></li> And within the ...

Updating MySQL Status Using PHP and JavaScript

I have a list of tasks that users can add dynamically. Each task has a checkbox next to it, and when checked, the status of that task in the MySQL database should be updated. My initial approach was to include the following code: echo "<input type=&ap ...

Error: Property '$filter' is not defined and cannot be read

Whenever a user clicks on a link, I display the json object on the UI. However, an exception is being thrown with the following message: TypeError: Cannot read property '$filter' of undefined Check out the demo here: http://plnkr.co/edit/5NOBQ3 ...

What are the ideal scenarios for implementing React.Fragments?

Today I discovered React Fragments and their benefits. I learned that fragments are more efficient by reducing the number of tree nodes and improving cleanliness in the inspector. However, is there still a need to use div tags as containers in React compo ...

Sending Objects Array in POSTMAN using Hapijs: A Step-by-Step Guide

Could you please assist me on how to send a POST request in POSTMAN for the given array of objects and then validate it using Joi in a hapi server? var payload = [{ name: 'TEST Name 1', answer: 'TEST Answer 1', category: &a ...

How to manage ajax URLs across multiple pages?

I have my website set up at http://example.com/foo/ within a directory, separate from the main domain. Through the use of .htaccess, I've configured the URLs to appear as http://example.com/foo/about/, http://example.com/foo/polls/, http://example.com ...

Choosing text input after adding a dynamic HTML row can be done by identifying the specific characteristics

I am currently working on a CodeIgniter project where I have implemented a purchase form that allows users to search for spare parts items using autocomplete in an input text field. The initial search functionality is working fine, but when I try to add a ...

Cancelling an ongoing AWS S3 upload with Angular 2/Javascript on button click

I'm currently working with Angular 2 and I have successfully implemented an S3 upload feature using the AWS S3 SDK in JavaScript. However, I am now facing a challenge: how can I cancel the upload if a user clicks on a button? I've attempted the ...

Customize the position values of the Ngx-bootstrap Tooltip manually

I have incorporated ngx-bootstrap into my Angular 4 application. The component I am using is ngx-bootstrap Tooltip: After importing it, I am implementing it in my component's view like this: <button type="button" class="btn btn-primary" ...

Retrieve the height of an element containing images, even if the images have not finished loading

After making an Ajax call and inserting some HTML code, I require the height of the newly added div in the Ajax callback. However, the issue arises because the HTML from the Ajax call contains elements like images that need to be loaded first. I have crea ...

Difficulty encountered when transferring an array from Xcode to JavaScript via SBJSON

In an attempt to transfer an array from Xcode to a local HTML file, I am utilizing jQuery in the HTML code. This involves using loadHTMLString: with baseURL to read both the HTML and included .js files. However, I am encountering an issue when trying to us ...

Transferring information to the server with JSON in the Codeigniter framework

I have a JavaScript array (unitdata_set) that I need to send to the server for database processing using Codeigniter. JavaScript Array (unitdata_set):- [{"unit_id":"13","unit_title":"Testsdsdf","unit_max_occupancy":"3","unit_no":"1","unit_no_adults":"1", ...

Utilizing Web Worker threads to enhance performance in Google Maps

Currently, I am experimenting with web worker threads to retrieve directions between various pairs of locations simultaneously and save the data in a file at the end. The process worked smoothly when attempted sequentially. I am using npm live-server to sh ...

react scroll event not displaying drop shadow

As a newcomer to JavaScript React, I've been attempting to create a feature where the navbar drops a shadow when the user scrolls down. Unfortunately, it's not working as intended. Can anyone point out what I might have done incorrectly? I suspe ...

How can I turn off Angular Grid's virtualization feature, where Angular generates div elements for the grid based on height and width positions?

Currently, I am working with an Angular grid (ag-grid) that dynamically creates div elements in the DOM to display data as the user scrolls or views different sections. As part of my testing process using Selenium WebDriver, I need to retrieve this data fr ...