我有一個問題,試圖設置一個快速+角度的應用程序。Experess.js + angularjs單獨路由
我可以加載資產文件到它。
我會在這裏發表我的代碼從快遞和html文件。據我看到,Express只返回index.html文件,沒有其他任何東西,使所有的路線返回該文件。
這裏是快遞代碼:
//server.js
// set up ========================
var express = require('express'),
bodyParser = require('body-parser'),
morgan = require('morgan'),
path = require('path'),
app = express(),
mongoose = require('mongoose'),
jwt = require('jsonwebtoken'), // used to create, sign, and verify tokens
config = require('./config'), // get our config file
User = require('./model/users'), //get our mongo model
routes = require('./middleware/routes');
// configuration =================
//var port = process.env.PORT || 8080;
app.use(express.static('/client'));
app.use(morgan('dev'));
app.use(bodyParser.urlencoded({'extended':'true'}));
app.use(bodyParser.json());
app.use(bodyParser.json({ type: 'application/json' }));
mongoose.connect(config.database);
app.set('superPin', config.secret);
// start server =================
//
app.listen(8080);
console.log('App strated and is listening on the port 8080');
//
app.get('/checkServer', function(request,response){
response.send('Works fine. Server started at default get routing to check if server runns.');
});
//
app.get('*',function(request,response){
response.sendFile(path.resolve('../client/view/index.html'));
});
//
//exports = module.exports = app;
,這裏是我的index.html文件:
<!DOCTYPE html>
<html>
<head>
<title>My </title>
</head>
<body ng-app="pmt">
<div ng-view></div>
<script src="client/assets/vendor/angular/angular.min.js"></script>
<script src="client/assets/vendor/angular-bootstrap/ui-bootstrap.min.js"></script>
<script src="client/assets/vendor/angular-message/angular-message.min.js"></script>
<script src="client/assets/vendor/angular-touch/angular-touch.min.js"></script>
<script src="client/assets/vendor/angular-ui-router/angular-ui-router.min.js"></script>
<script src="client/assets/vendor/angular-touch/angular-touch.min.js"></script>
<script src="client/assets/vendor/moment/min/moment.min.js"></script>
<script src="client/controller/routes.js"></script>
</body>
</html>
這裏是回購的鏈接:https://bitbucket.org/cojok/pmt/
我看到了其他相關帖子,但我無法找到我做錯了什麼。
你究竟想要做什麼?你想要服務器端路由還是要角路由? –
不能得到你在做什麼錯誤,你需要幫助? – prasun
我正在嘗試使角度路由,但我無法加載我需要的文件。我總是得到這個愚蠢的錯誤,未捕獲的SyntaxError:意外的標記
cojok