我对 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/