0

I am having a problem with Angular JS receiving an error

jquery.js:7993 Uncaught Error: [$injector:modulerr] Failed to instantiate module application due to:
Error: [$injector:nomod] Module 'application' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

my controller is controller.js as follows

angular.module('application') .controller( 'controller', [ '$scope', 'service', '$uibModal', '$uibModalStack','$rootScope', function($scope, service, $uibModal, $uibModalStack,$rootScope) {}]);

and my service is service.js as follows

angular.module('application').service('service',
        [ '$resource', function($resource) {
            var requstService = $resource('test', {}, {

            });
            return requstService;
        } ]);

when i load the view page it running perfectly but when i click again on site link it showing above error.Please help.

5
  • check this Commented Feb 1, 2017 at 8:01
  • Have you loaded your js files in the correct order? Commented Feb 1, 2017 at 8:02
  • Yes i am loading scripts file dynamically.when i click First time then it working but not on second click. Commented Feb 1, 2017 at 8:06
  • 1
    Just to give context to all the 'add []' answers. If you omit the [] Angular will try to search for a module that you already created by the name and return it. Adding the array instructs Angular you want to create the module. It's one of the most common causes for your error, hence the answers. Commented Feb 1, 2017 at 8:51
  • @ste2425 Not working Commented Feb 1, 2017 at 9:44

3 Answers 3

1

Your controller should be,

angular.module('siteApplication',[]) .controller( 'siteController', [ '$scope', 'siteService', '$uibModal', '$uibModalStack','$rootScope', function($scope, siteService, $uibModal, $uibModalStack,$rootScope) {
Sign up to request clarification or add additional context in comments.

Comments

0

your module is missing [] your controller should be like:

angular.module('siteApplication',[])

also did you not paste the ending part of the controller i.e } ]); on purpose ?

Comments

0

Use [] in your controller to create module like this.

angular.module('moduleName', [])

and use this in your html page like ng-app="moduleName"

and add dependency js file related to $uibModal.

1 Comment

please add js file related to $uibModal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.