Kratos
Kratos

Reputation: 1114

Angular Failed to instantiate module after renaming it

I had an Angular module named "sample" and angular debugging console was asking me to rename it to "appname.sample", I did that and I also changed the calling of the module. But angular seems to be still looking for module sample. and I am getting the error:

$injector:modulerr] Failed to instantiate module decisionone due to: Error: [$injector:nomod] Module is not available! You either misspelled the module name or forgot to load it

Where else am I supposed to change it?

Here is the code:

angular.module('appname.sample', ['ngRoute', 'common', 'ngSanitize'])

and when I am including it: angular.module('appname.sample')

Upvotes: 1

Views: 740

Answers (3)

Moshe Yakov
Moshe Yakov

Reputation: 101

Could it be maybe that you made already a different module dependent on your sample module something like this:

angular.module('someDifferentModule', ['sample'])

If so you have to rename it here as well:

angular.module('someDifferentModule', ['appname.sample'])

Also, based on the Angular error, it seems that the problem is not with your app.sample but rather with a module named decisionone

$injector:modulerr] Failed to instantiate module decisionone due to: Error: [$injector:nomod] Module is not available! You either misspelled the module name or forgot to load it

Are you injecting this some where like this:

angular.module('someModule', ['decisionone'])

and desicionone was never instantiated as a module?

Upvotes: 0

Mike Feltman
Mike Feltman

Reputation: 5176

In your index.html file page you should have ng-app="your module name" on a tag somewhere, probably the body tag. Change this to match your new module name.

Upvotes: 1

Lahar Shah
Lahar Shah

Reputation: 7654

If you have your config file/route file for that module some where else. Make sure you are also changing that module name.

For example in ngRoute if config and rout specification are defined separately I also need to make module name to be same.

angular.module('appname.sample', []);

angular.module('appname.sample').config(['$routeProvider', function($routeProvider) {

        $routeProvider
            .when("/urlPath", {
                controller: 'controllerName',
                templateUrl: 'modules/pathToViewPage/view.html',
            });
    }
]);

Upvotes: 1

Related Questions