【问题标题】:Module 'moduleName' is not available! You either misspelled the module name or forgot to load it模块“moduleName”不可用!您要么拼错了模块名称,要么忘记加载它
【发布时间】:2016-07-21 04:56:34
【问题描述】:

我是新的 Angular,我必须在我的项目中实现服务器端分页,所以我做了所有事情,就像在这个例子中所做的那样: Server Side Pagination In Angularjs Tutorials

但我在我的网络浏览器控制台中收到这些错误:

GET 
http://*********/admin/css/bootstrap.min.css [HTTP/1.1 404 Not Found 1043ms]

GET 
http://*********/admin/css/bootstrap-theme.min.css [HTTP/1.1 404 Not Found 1385ms]

GET 
http://*********/admin/css/styles.css [HTTP/1.1 404 Not Found 1334ms]

GET 
http://*********/admin/lib/angular/angular.js [HTTP/1.1 404 Not Found 1384ms]

GET 
http://*********/admin/lib/dirPagination.js [HTTP/1.1 404 Not Found 1383ms]

GET 
http://*********/admin/app/app.js

and

Error: [$injector:modulerr] Failed to instantiate module angularTable due to:
[$injector:nomod] Module angularTable 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.

如果有人可以帮助我,请!

【问题讨论】:

  • 您的资源似乎没有正确地从服务器传输到浏览器。检查网址是否正确。
  • 模块 angularTable 的源代码位于 dirPagination.js 中,如果未正确检索,则会发生此错误。如果 dirPagination.js 本身的 url 正常工作,我假设存在某种 CORS 问题。
  • 不,找不到这个资源,但是 URL 没问题

标签: angularjs


【解决方案1】:

这通常发生在您执行类似...的操作时

angular.module('myapp').controller(function() {
});

请注意,此代码不会创建名为 myapp 的模块,它只是引用现有模块。如果您尚未创建模块,则会发生您遇到的错误。

要创建模块,请执行此操作...

angular.module('myapp', []);

另外,不要忘记 HTML 中的 ng-app 指令...

<html ng-app="myapp">

当然,这假设您的脚本文件加载正确。根据您的问题,您的文件无法加载,因此 myapp 尚未创建也就不足为奇了。您应该检查您尝试加载的文件是否确实存在于您的服务器上。还要确保您知道哪个文件夹是您的 Web 服务器提供文件的根文件夹。这将帮助您获得正确的文件路径。

【讨论】:

  • 我按照你的建议做了。这是我的 app.js(就像我上面提到的示例一样)
  • 你修好了 404s 吗?在你没有得到 404s 之前,这将不起作用
  • 我可以得到我的 index.php 页面。我的文件夹结构就像这里 github.com/rahil471/Server-Side-Pagination-In-AngularJS 和我的 index.php 包含
  • 你得到 HTTP/1.1 404 Not Found 吗?
  • 好的,你必须先解决这个问题 - 确保文件路径正确
猜你喜欢
  • 2017-09-26
  • 2017-06-29
  • 1970-01-01
  • 2014-12-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-09-27
  • 1970-01-01
相关资源
最近更新 更多