Угловая ошибка в стеке MEAN - ошибка Uncaught: $ инжектор: modulerr

0

Я делаю простой в стеке MEAN, код начинается нормально в начале, когда я кодирую пару строк больше Angular, показывает мне ошибку. Что я делаю неправильно? Я не могу следить за курсами интернет-курса MEAN для этой проблемы. PLease поможет в решении этой проблемы.

Html Код индекса.

<html ng-app="myApp">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Contact list App</title>
    <link rel="stylesheet" href="css/metro-bootstrap.min.css" />
</head>
<body>
    <div class="container" ng-controller="AppCtrl">
        <section class="row">
            <div class="col-lg-12 text-center">
                <h1>This is a MEAN stack - Contact list!</h1>
                    <table class="table">
                        <thead>
                            <tr>
                                <th class="text-center">Name</th>
                                <th class="text-center">Email</th>
                                <th class="text-center">P. Number</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr ng-repeat="contact in contactist">
                                <td>{{contact.name}}</td>
                                <td>{{contact.email}}</td>
                                <td>{{contact.number}}</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
        </section>
    </div>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/metro-docs.js"></script>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.12/angular.min.js"></script>
    <script type="text/javascript" src="controllers/controller.js"></script>
</body>

контроллер

var myApp = angular.module('myApp', ['ngRoute']);function AppCtrl($scope, $http) {
console.log("Hello world from controller.js");

$http.get('/contactlist').success(function (response) {
    console.log("I got the data");
    $scope.contactList = response;
});}

сервер

var express = require('express');
var app = express();
app.use(express.static(__dirname + "/public"));

app.get('/contactList', function (req, res) {
    console.log("I got the request!");

    person1 = {
        name: 'Tim',
        email: '[email protected]',
        number: '(111) 11-11-111'
    };
    person2 = {
        name: 'Rod',
        email: '[email protected]',
        number: '(211) 11-11-111'
    };
    person3 = {
        name: 'Eddie',
        email: '[email protected]',
        number: '(311) 11-11-111'
    };

    res.json([person1, person2, person3]);
});

app.listen(3000);
console.log("Server running from port 3000");

Это ошибка: Ошибка при сбое: [$ injector: modulerr] [Ошибка AngularJs] 1

Изображение 174551

Теги:
mean-stack

1 ответ

1
Лучший ответ

Похоже, что ваш контроллер не подключен - вы заявили о функции, но не сказали об этом. Попробуй это:

var myApp = angular.module('myApp', ['ngRoute'])

myApp.controller('AppCtrl', function($scope, $http) {
    console.log("Hello world from controller.js");

    $http.get('/contactlist').success(function (response) {
      console.log("I got the data");
      $scope.contactList = response;
   });
});

Также я не вижу признаков того, что загрузка тега скрипта является угловой, но она должна быть там, чтобы получить сообщение об ошибке. Помните ли вы также включить ngRoute, например?

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.6/angular-route.js"></script>
  • 0
    У него такая же ошибка. Это не изменилось! :(
  • 0
    Это ошибка: Uncaught Ошибка: [$ Инжектор: modulerr] errors.angularjs.org/1.3.12/$injector/... ... gleapis.com% 2Fajax% 2Flibs% 2Fangularjs% 2F1.3.12% 2Fangular.min.js% 3A17 % 3A381)
Показать ещё 9 комментариев

Ещё вопросы

Сообщество Overcoder
Наверх
Меню