【发布时间】:2016-06-01 14:28:54
【问题描述】:
我正在制作一个简单的 MEAN 堆栈,代码从一开始就很好,当我再编写几行代码时,Angular 向我显示了一个错误。我做错了什么?对于这个问题,我无法关注 Internet MEAN 堆栈课程。 请帮助解决这个问题。
索引的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: 'tim@domain.com',
number: '(111) 11-11-111'
};
person2 = {
name: 'Rod',
email: 'rod@domain.com',
number: '(211) 11-11-111'
};
person3 = {
name: 'Eddie',
email: 'eddie@domain.com',
number: '(311) 11-11-111'
};
res.json([person1, person2, person3]);
});
app.listen(3000);
console.log("Server running from port 3000");
这是错误:未捕获的错误:[$injector:modulerr] [AngularJs 错误]1
【问题讨论】:
标签: angularjs node.js mean-stack