Angular and Express routing

前端 未结 4 1480
日久生厌
日久生厌 2020-12-02 07:30

I\'ve been through many Angular-express seeds and kind of worked out how they work. The problem I am having is: 1). I would like to use ejs-locals for temp

4条回答
  •  情书的邮戳
    2020-12-02 08:16

    You can try something like this,

    const path = require("path");
    
    /* For serving static HTML files */
    app.use(function(req, res, next) {
        res.sendFile(path.resolve(__dirname + '/dist/index.html'));
    });
    
    /* For ejs, jade/pug engines */
    app.use(function(req, res, next) {
        res.render(path.join(__dirname, '/dist/index.pug'));
    });
    

提交回复
热议问题