2016-05-13 126 views
1

我有一个名为“sample”的Angular模块,角度调试控制台要求将其重命名为“appname.sample”,我这样做了,并且我还更改了模块的调用。 但角似乎仍在寻找模块样本。我得到的错误:Angular在重命名后无法实例化模块

$ injector:modulerr]无法实例化模块decisionone由于:错误:[$ injector:nomod]模块不可用!你拼错了模块名或忘了加载它

我还要在哪里改变它?

下面是代码:

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

,当我包括它: angular.module(“appname.sample”)

回答

0

莫非也许,你已经做出不同的模块依赖您sample模块是这样的:

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

如果让你不得不在这里以及重命名:

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

此外,基于对角误差,似乎问题不在于你的app.sample而是与一个名为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

你注入这部分在哪里这样的模块:

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

desicionone从未被实例化为模块?

1

如果您有该模块的配置文件/路由文件,还有其他地方。确保您也在更改该模块名称。

例如在ngRoute中,如果配置和路由规范分别定义,我还需要使模块名称相同。

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

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

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

谢谢你们俩!它现在有效! – Kratos

1

在你的index.html文件页面,你应该在标签的某个地方有ng-app =“你的模块名”,可能是body标签。将其更改为与您的新模块名称相匹配。

+0

是的!它是固定的! TY – Kratos

相关问题