模块不可用,拼写错误或忘记加载(但我没有) [英] Module is not available, misspelled or forgot to load (but I didn't)

查看:92
本文介绍了模块不可用,拼写错误或忘记加载(但我没有)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am fairly new to angular and using it with JSON api files. TO test, I am trying to use the free github api (my names for functions are for a different json api that i will be working with later). I just wanted to see if my functions were working with console.log(), but i receive this error in the console.


未捕获错误:[$ injector:modulerr]无法实例化模块
MesaViewer由于:错误:[$ injector:nomod]模块'MesaViewer'不是
可以!您要么错误拼写了模块名称,要么忘记加载它。
如果注册模块,请确保将依赖关系指定为
第二个参数。

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 两者完全相同,并且在第二行中看到依赖关系!

I have spelled MesaViewer the exact same in both, and dependencies are seen in the second line!

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

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

推荐答案

它应该是

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

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

This is the syntax you need to define a module and you need the array to show it has no dependencies.

你使用

angular.module("MesaViewer");

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

syntax when you are referencing a module you've already defined.

这篇关于模块不可用,拼写错误或忘记加载(但我没有)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆