【发布时间】:2018-01-02 03:32:10
【问题描述】:
我有一个mean-stack 项目。在我的index.js,我到底有没有
router.get('*', function(req, res) {
res.sendfile('./views/index.html');
})
module.exports = router;
现在我想通过./views/addinIndex.html 处理与https://localhost:3000/1/addin/* 匹配的所有网页,我希望在其中引用不同的外部文件并定义不同的模块。因此,我添加了另一个router.get:
router.get('/1/addin/*', function (req, res) {
res.sendfile('./views/addinIndex.html')
})
router.get('*', function(req, res) {
res.sendfile('./views/index.html');
})
module.exports = router;
这里是addinIndex.html:
<html>
<head>
<script src="https://code.jquery.com/jquery.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.3.2/angular-ui-router.js"></script>
<script>
jQuery(document).ready(function () {
angular.bootstrap(document, ['app']);
console.log("bootstrapped")
})
app = angular.module('app', ['ui.router'])
app.config(['$stateProvider', function($stateProvider) {
$stateProvider
.state('addinHome1', {
url: '/1/addin/home',
template: 'addinHome1'
})
.state('addinHome2', {
url: '/addin/home',
template: 'addinHome2'
})
.state('addinHome3', {
url: '/home',
template: 'addinHome3'
})
}])
</script>
</head>
<body>
abcde
<ui-view ng-cloak></ui-view>
</body>
</html>
但是,当我运行https://localhost:3000/1/addin/home 时,它只显示abcde 而没有其他任何内容,而bootstrapped 打印在控制台中。
有谁知道怎么回事?我可以像这样定义一个额外的addinIndex.html,因为我已经有一个工作的index.html?
【问题讨论】:
标签: javascript angularjs express angular-ui-router mean-stack