javascript - 模块不可用、拼写错误或忘记加载(但我没有)

标签 javascript json angularjs module angularjs-injector

我对 Angular 相当陌生,并且将它与 JSON api 文件一起使用。为了测试,我正在尝试使用免费的 github api(我的函数名称是用于稍后我将使用的不同的 json api)。我只是想看看我的函数是否与 console.log() 一起工作,但我在控制台中收到此错误。

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

我将 MesaViewer 拼写成完全相同,并且在第二行中可以看到依赖关系!

var app = angular.module("MesaViewer");
var MainController = function($scope, $location, $http, $routeParams) {

我做错了什么? 这是我的笨拙:http://plnkr.co/edit/sZPaFbzbOB6AmVCLL1vq

最佳答案

应该是

var app = angular.module("MesaViewer", []);

这是定义模块所需的语法,并且需要数组显示它没有依赖关系。

你使用

angular.module("MesaViewer");

引用已定义模块时的语法。

关于javascript - 模块不可用、拼写错误或忘记加载(但我没有),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31394850/

相关文章:

php - 使用 javascript 重置表单将不起作用

javascript - 创建计算字段的报价摘要

ios - NSJSONSerialization 和 SBJson 工作异常

jquery - 支持网络和移动应用程序的架构方法

javascript - 如何访问具有 json 字符串的 javascript 对象中的特定键值对

javascript - 使用 ng-click 在函数中传递对象

javascript - 检查是否在下拉多项选择中选择了多个选项

Javascript 在异步循环结束时执行

javascript - ng-模型列表未在 Angular js 中更新

javascript - 以 Angular 生成 JSON 对象的聚合数组