node.js - 需要 Angular 5 中的特定 URL
问题描述
(NodeJS 9.4 和 Angular 5)。
// In app.js I have,
app.use('/', login);
app.use('/app', application);
// in the route file application.js, I have,
router.get('/', function(req, res, next) {
res.render("application/index");
});
// in angular 5 I have
{
path : 'angular_path',
component : AngularComponent
},{
path : '**',
redirectTo: 'angular_path'
}
现在,当我输入 URL 时
localhost:3000/app
,它会将我带到
localhost:3000/#/angular_path
所有这些对我来说都很好,但是现在当我刷新页面时,它会将我发送回登录页面,这就是我需要 URL 的原因
localhost:3000/app/#/angular_path
我需要在 /app/
角度路线之前使用这个词。
||帮助||
解决方案
尝试使用此代码在 URL 中设置前缀。
在 app.js 中添加此代码
var router = express.Router();
app.use('/app', router);
推荐阅读
- c# - 如何根据参数将数据插入到两个表中
- javascript - 是否可以检测何时在 JavaScript 中创建 ES6 类的第一个实例?
- selenium - 硒按钮单击python
- python - 如何使用 Python 发出 URL 请求并返回重定向到的 URL?
- prolog - 如何在 ECLIPSE-CLP 或 Prolog 中实现这些 Sigma 符号
- electron - 如何将电子生成器与目标便携式设备一起使用?
- python - 打印语句的问题
- vb.net - 如何在 vb.net 的查询字符串中不通过 $expand 来扩展(odata-webapi)所有属性
- python - 如何在 Python 中以附加模式打开 /etc/hosts 文件?
- regex - 使正则表达式以懒惰的方式匹配,同时跳过一些单词