由于以下原因无法实例化模块marbleApp:错误:[$ injector:nomod]

时间:2016-04-08 15:45:25

标签: angularjs

由于以下原因导致无法实例化模块marbleApp: 错误:[$ injector:nomod]模块' marbleApp'不可用!您要么错误拼写了模块名称,要么忘记加载它。如果注册模块,请确保将依赖项指定为第二个参数。

我几乎阅读了每篇文章并在文档中搜索过,但我的应用程序无法正常工作,因为我的模块未加载。任何人都可以在代码中发现任何阻止其无法正常工作的错误吗?

的index.html:

<!DOCTYPE html>
  <html ng-app="marbleApp">
    <head>
      <title>Marble.com AngularMongo</title>
      <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
      <!--Import materialize.css-->
      <link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
      <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.6/css/materialize.min.css"  media="screen,projection"/>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.3/angular.js"></script>
      <script src="app.js"></script>  

    </head>

    <body>

      {{"anot" + "her test"}}

      <nav style="background-color: #d56324!important">
        <div class="nav-wrapper">
          <form action="/cosmicblack" method="GET">
            <div class="input-field">
              <input id="search" type="search" required placeholder="Search">
              <label for="search"><i class="material-icons">search</i></label>
              <i class="material-icons">close</i>
            </div>
          </form>
        </div>
      </nav>
      <br>

      <div>
    {{"This is " + "a test!"}}
    {{materials.name}}
      </div>
    <!-- <div ng-controller="repeatCtrl">{{materials.name}}</div> -->



    <div class="container">
     <div class="row">  


        <div class="col m3" ng-controller='repeatCtrl'>
          <a href="/cosmicblack"><div class="card">
            <div class="card-image small">
                <img src="http://marble.com/uploads/materials/499/300X300/thumbnail/Cosmic-Black_APeruB9I056YsF3mZ0sT.jpg">
                <span class="card-title" ng-bind="materials.name"></span>
              </div>
            </div>
          </a>
        </div>


      </div>
    </div>







      <!--Import jQuery before materialize.js-->

      <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.6/js/materialize.min.js"></script>


    </body>
  </html>

app.js:

var app = angular.module('marbleApp', []);

app.controller('repeatCtrl', function($scope) {
    $scope.materials = [
        {name: 'Cosmic Black'}
    ];      
});

server.js:

console.log('May Node be with you');

var express = require('express');
var bodyParser = require('body-parser');
var app = express();
var mongoose = require('mongoose');

mongoose.connect('mongodb://localhost/test');
var db = mongoose.connection;

app.use(bodyParser.urlencoded({extended: true}))

app.get('/', (req, res) => {
    res.sendFile(__dirname + '/index.html');
});



app.get('/cosmicblack', (req, res) => {
    var cursor = db.collection('materials').find();
    db.collection('materials').find({"id": "499"}).toArray(function(err, results) {
        console.log(results);
    });
    db.collection('materialphotos').find({"material_id": "499"}).toArray(function(err, results2) {
        console.log(results2);
    });
    res.redirect('/');
});



app.listen(3000, () => {
    console.log('Running app.js on 3000');
});

1 个答案:

答案 0 :(得分:0)

我复制了与你相同的代码,它对我有用。看一下这个bin。角度nomod错误的常见原因是,angular.js或您应用的任何依赖项未正确加载导致您的应用模块无法正确加载