【发布时间】:2015-02-13 00:04:53
【问题描述】:
我是 MEAN Stack 的新手。我用一些 angularJS 在 html 中尝试了一些非常基本的东西,当我在浏览器中打开它时它正在工作。但不幸的是,当我尝试用我的 nodeJS 服务器渲染它时,代码不再工作了。 index.html 已显示,但角度部分不再起作用。我的输出只是 {{article}}。你有什么建议吗?
index.html
<html ng-app="ibrahimsBlog">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Ibrahims Blog</title>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
<script src="app.js"></script>
</head>
<body>
<div ng-controller="articleController">
<div ng-repeat="article in articles">
{{article}}
</div>
</div>
</body>
</html>
app.js
var app = angular.module('ibrahimsBlog', [])
app.controller('articleController', [
'$scope',
function($scope) {
$scope.articles = [
'foo',
'bar',
'baz'
];
}]);
还有我非常基本的节点服务器:
var express = require('express'), app = express();
app.get('/', function(req, res) {
res.sendFile(__dirname + '/index.html');
});
app.listen(3000, function() {
console.log('Server listening on port 3000');
});
【问题讨论】:
标签: angularjs node.js mean-stack