首页 > 解决方案 > 需要 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/角度路线之前使用这个词。

||帮助||

标签: node.jsangularurlangular5angular6

解决方案


尝试使用此代码在 URL 中设置前缀。

在 app.js 中添加此代码

var router = express.Router();
app.use('/app', router);

推荐阅读