nodeJS无法加载角度

时间:2017-06-02 04:09:32

标签: angularjs node.js express

我有关于nodeJS的问题,我正在尝试学习nodeJS和几乎初学者。

这里是文件夹的位置:
- 申请书 - 控制器
--- mainController.js
- lib
--- js
---- angular.min.js
- 意见
--- index.html
- 路线
- server.js

所以我有这个server.js并且它正在运行:

var express = require('express'),
app = express(),
port = process.env.PORT || 3000;
var routes = require('./routes/routes');

app.use(express.static(__dirname + '/application')); //static path
routes(app);

app.get('/', function(req,res){
    res.sendFile(__dirname + "/application/views/index.html")
});

app.listen(port);
console.log('server started on: ' + port);

但是index.html中没有加载angularJS:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Testing Web</title>    
    <!-- LOAD JS -->
    <script src="../lib/js/angular.min.js"></script>
    <script src="../controllers/mainController.js"></script>    
</head>    
<body>
{{greetings}}
</body>    
</html>

任何人都有解决方案吗?

1 个答案:

答案 0 :(得分:0)

您的ng-appng-controller在哪里?你需要将它们添加到HTML

<!DOCTYPE html>
<html lang="en" ng-app="your_module">
<head>
    <meta charset="UTF-8">
    <title>Testing Web</title>    
    <!-- LOAD JS -->
    <script src="../lib/js/angular.min.js"></script>
    <script src="../controllers/mainController.js"></script>    
</head>    
<body ng-controller="your_ctrl">
{{greetings}}
</body>    
</html>