I’m relatively new to Angular and I’m facing an issue while trying to run an Angular page. No matter what I do, I keep encountering an error stating that I have not created an Angular module.
Encountered an error when trying to instantiate the HotelApp module:
Error: [$injector:nomod] http://errors.angularjs.org/1.5.3/$injector/nomod?p0=Hote... blah blah blah
My code looks like this:
(function () {
"use strict";
angular.module(APPNAME)
.factory('$hotelService', hotelServiceFactory);
hotelServiceFactory.$inject = ['$methodRepository', $methodRepository];
function hotelServiceFactory($methodRepository) {
var hotelServiceObject = AjaxScripts;
console.log("Hotel Service", hotelServiceObject);
}
})();
(function () {
"use strict";
angular.module(APPNAME)
.controller("HotelController", hotelController);
hotelController.$inject = ['$scope', '$hotelService'];
function TracksController($scope, $hotelService) {
I’m confused as to why it’s stating that my module is not instantiated when I have declared the APPNAME variable in both the script and in the ng-app.
Edit: I currently have:
(function () {
"use strict";
angular.module("HotelApp", [])
.factory('$hotelService', hotelServiceFactory);
hotelServiceFactory.$inject = ['$methodRepository', $methodRepository];
function hotelServiceFactory($methodRepository) {
var hotelServiceObject = AjaxScripts;
console.log("Hotel Service", hotelServiceObject);
}
})();
However, it is still not functioning as expected.