I encountered an issue with AngularJS where I am struggling to import a Service from one module to another. In the Data module, I have a Service named MenuDataService that I need to utilize in the MenuApp module. However, when attempting to do so, I receive an error message referencing this link.
Within src/data-module/data.module.js:
angular.module('Data', []);
In src/data-module/menudata.service.js:
angular.module('Data')
.constant('CATEGORIES_URI', 'some_uri')
.service('MenuDataService ', MenuDataService);
MenuDataService.$inject = ['$http', 'CATEGORIES_URI'];
function MenuDataService($http, CATEGORIES_URI) {
var service = this;
service.getAllCategories = function () {
return httpRequest(CATEGORIES_URI);
};
};
In src/menuapp-module/menuapp.module.js:
angular.module('MenuApp', ['Data']);
In src/menuapp-module/categories.controller.js:
angular.module('MenuApp')
.controller('CategoriesController', CategoriesController);
CategoriesController.$inject = ['MenuDataService'];
function CategoriesController(MenuDataService) {
console.log('CATEGORIES CONTROLLER');
};
index.html:
<script type="text/javascript" src="./lib/angular.min.js"></script>
<script type="text/javascript" src="./src/data-module/data.module.js"></script>
<script type="text/javascript" src="./src/data-module/menudata.service.js"></script>
<script type="text/javascript" src="./src/menuapp-module/menuapp.module.js"></script>
<script type="text/javascript" src="./src/menuapp-module/categories.controller.js"></script>
If anyone could offer assistance, I would greatly appreciate it as I'm unsure of what mistake I might be making...
Thank you for your help!