view raw
Rodolfo A. Calvo Jaubert Rodolfo A. Calvo Jaubert - 11 months ago 61
AngularJS Question

Angular error in MEAN stack - Uncaught Error: $injector:modulerr

I am making a simple in MEAN stack, the code starts fine at the beginning, when I code a couple of lines more Angular shows me an error. What I am doing wrong? I cannot follow with the Internet MEAN stack courses for this issue.
PLease help with this issue.

Html Code of index.

<html ng-app="myApp">
<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" />
<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">
<th class="text-center">Name</th>
<th class="text-center">Email</th>
<th class="text-center">P. Number</th>
<tr ng-repeat="contact in contactist">
<script src=""></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/metro-docs.js"></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src="controllers/controller.js"></script>


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: '',
number: '(111) 11-11-111'
person2 = {
name: 'Rod',
email: '',
number: '(211) 11-11-111'
person3 = {
name: 'Eddie',
email: '',
number: '(311) 11-11-111'

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

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

This is the error: Uncaught Error: [$injector:modulerr]
[AngularJs Error]1

enter image description here


It looks as though your controller is not wired up - you've declared the function, bit not told angular about it. Try this:

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;

Also I see no sign of the script tag loading angular, but it must be there to get the error message. Have you remembered also to include ngRoute, with e.g.?

<script src=""></script>