角JS,“NOMOD'模块'{0}”不可!你要么拼写错误 [英] Angular JS, 'nomod',Module '{0}' is not available! You either misspelled

查看:126
本文介绍了角JS,“NOMOD'模块'{0}”不可!你要么拼写错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是code在我的index.html

This is the code in my index.html

<html ng-app="">
<head>
<link rel="stylesheet" href="css/app.css">
<link rel="stylesheet" href="css/bootstrap.css">
<script src="lib/angular/angular.js"></script>
<script src="js/phoneControllers.js"></script>
<title ng-bind-template="Google Phone Gallery:{{query}}">Google Phone Gallery</title>
</head>
<body ng-controller="PhoneListCtrl">
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span2">
            Search:
            <input ng-model="query">
            Sory by: 
                <select ng-model="orderProp">
                    <option value="name">Alphabetical</option>
                    <option value="age">Newest</option>
                </select>
        </div>
        <div class="span10">
            <h1>{{Hello}}</h1>
            <p>Total number of phones:{{filtered.length}}</p>
            <ul class="phones">
                <li ng-repeat="phone in filtered=(phones | filter:query | orderBy:orderProp)" class="thumbnail">
                    <span>{{$index}}</span>
                    <a href="#/phones/{{phone.id}}" class="thumb"><img ng-src="{{phone.imageUrl}}" /></a>
                    <a href="#/phones/{{phone.id}}">{{phone.name}}</a>
                    <p>{{phone.snippet}}</p>
                </li>
            </ul>
        </div>
    </div>
</div>
<div id="currentFilter">Current filter: {{query}}</div>
<div id="currentOrderPrep">Current Order: {{orderProp}}</div>
<!--<div>{{phones|json}}</div>-->
</body>
</html>

当我由Chrome与Web检查打开它,它经常会抛出这样的:

When I open it by Chrome with Web Inspector, it often throws this:

return ensure(modules, name, function() {
    if (!requires) {
      throw $injectorMinErr('nomod', "Module '{0}' 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.", name);
    }

这是phoneControllers.js:

And this is the phoneControllers.js:

function PhoneListCtrl($scope, $http) {
    $http.get('phones/phones.json').success(function (data) {
    $scope.phones = data;
});
$scope.orderProp = "age";
};

但关闭Chrome网上督察时,所有运行平稳。
你能告诉我发生了什么?在此先感谢

But when closing Chrome Web Inspector, all ran smoothly. Could you tell me what happens? Thanks in advance

我读了angular.js code,看来这是错误角,无论何时,这个错误将被抛出。

I read the angular.js code, it seems this is the Angular bug, whenever, this error will be thrown.

 var $injectorMinErr = minErr('$injector');
 var ngMinErr = minErr('ng');

 function ensure(obj, name, factory) {
 return obj[name] || (obj[name] = factory());
 }

 var angular = ensure(window, 'angular', Object);

 // We need to expose `angular.$$minErr` to modules such as `ngResource` that reference it during bootstrap
 angular.$$minErr = angular.$$minErr || minErr;

 return ensure(angular, 'module', function() {
/** @type {Object.<string, angular.Module>} */
var modules = {};

return function module(name, requires, configFn) {
  var assertNotHasOwnProperty = function(name, context) {
    if (name === 'hasOwnProperty') {
      throw ngMinErr('badname', 'hasOwnProperty is not a valid {0} name', context);
    }
  };

  assertNotHasOwnProperty(name, 'module');
  if (requires && modules.hasOwnProperty(name)) {
    modules[name] = null;
  }
  return ensure(modules, name, function() {
    if (!requires) {
      throw $injectorMinErr('nomod', "Module '{0}' 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.", name);
    }

变量要求永远不会被定义。我是一个新鲜的,任何错误,请告诉我。

The variable requires never be defined. I'm a fresher, any mistake, please tell me.

推荐答案

我要你链接到AngularJS文档

I have to link you to AngularJS documentation

Angularjs $注射器:: NOMOD

这基本上说,你的模块应该定义为:

which basically says that your module should be defined as:

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

这篇关于角JS,“NOMOD'模块'{0}”不可!你要么拼写错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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