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

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

问题描述

我对 angular 和将它与 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) {

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

What did I do wrong? Here is my plunk: 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天全站免登陆