Angularjs 平均应用的变化根
我正在开发mean应用程序,我需要从另一个url(如(“/myApp”)而不是root)加载我的html和css,那么如何才能得到这个呢?我的意思是我想启动我的应用程序表单url“localhost:3003/myApp”,默认情况下它运行在“localhost:3003/”上 我的配置文件是Angularjs 平均应用的变化根,angularjs,node.js,express,mean-stack,Angularjs,Node.js,Express,Mean Stack,我正在开发mean应用程序,我需要从另一个url(如(“/myApp”)而不是root)加载我的html和css,那么如何才能得到这个呢?我的意思是我想启动我的应用程序表单url“localhost:3003/myApp”,默认情况下它运行在“localhost:3003/”上 我的配置文件是 var express = require('express'), routes = require('./routes'), fs = require('fs'),
var express = require('express'),
routes = require('./routes'),
fs = require('fs'),
bodyParser = require('body-parser'),
router = express.Router();
var port = 80;
var app = module.exports = express();
// Configuration
//app.use(router);
app.use(bodyParser());
//app.use(express.methodOverride());
app.use(express.static(__dirname + '/dev'));
//app.use(express.compress());
app.all('*', function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Content-Type, Authorization, Content-Length,X-Requested-With");
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
next();
})
router.get('/', routes.index);
router.get('/template/:name', routes.partials);
// JSON API
router.get('/api/name', routes.name);
// redirect all others to the index (HTML5 history)
router.get('*', routes.index);
app.use('/', router);
app.listen(3003, function(){
console.log("Express server listening on port mode");
});
process.on('uncaughtException', function (err) {
console.log((new Date).toUTCString() + ' uncaughtException:', err.message)
console.log(err); //process.setMaxListeners(0);
// process.setMaxListeners(0);
process.exit(1)
})
更改:
app.use(“/”,路由器)代码>到app.use('/myApp',路由器)代码>您的意思可能是,我还必须更改angularjs rounting中的.state('home',{url:'/explorer',templateUrl:'views/main/partials/home.html})抱歉,但这不起作用,所有java脚本文件都在加载,但html不会出现