【问题标题】:mean angular 2 express: get route() only returns "/" routemean angular 2 express: get route() 只返回“/”路由
【发布时间】:2016-12-20 19:33:44
【问题描述】:

您好,我正在创建一个 Angular2 平均堆栈应用程序。我相信第二条路由的调用没有正确调用。网络响应是 html 而不是 JSON

import express = require('express');
import path = require('path');

import ContactRoutes = require('../routes/ContactRoutes');
import EstimateRoutes = require('../routes/EstimateRoutes');
var app = express();

class Routes {
    get routes() {
        app.use("/", new ContactRoutes().routes);
        app.use("/estimates", new EstimateRoutes().routes);
        return app;
    }
}
export = Routes;

【问题讨论】:

    标签: angular express mean-stack


    【解决方案1】:

    已解决:我找到的解决方案是将根“/”添加到两种用途。

    app.use("/", new ContactRoutes().routes);
    app.use("/", new EstimateRoutes().routes);
    

    不确定路线是如何确定的,但它可以工作。

    【讨论】:

    • EstimateRoutes 中的路由可能已经包含前缀。
    猜你喜欢
    • 2018-05-26
    • 2016-09-01
    • 2018-04-22
    • 2023-01-13
    • 1970-01-01
    • 2016-11-12
    • 2015-10-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多