【问题标题】:set json file as route in Angular Universal在 Angular Universal 中将 json 文件设置为路由
【发布时间】:2019-10-15 18:04:42
【问题描述】:

我是角度通用的新手,我正在尝试在路由中公开一个 json 文件。我想通过如下代码的路径公开一个 json 文件。我怎样才能在角度通用中实现这一点?

  // Redirect root path to /atlassian-connect.json,
    // which will be served by atlassian-connect-express.
    app.get('/', (req, res) => {
        res.redirect('/atlassian-connect.json');
    });

【问题讨论】:

    标签: angular angular-universal


    【解决方案1】:

    我会制作一个组件并通过 http: 获取文件:

    this.http.get('./atlassian-connect.json').subscribe(data => {
        // set json file to variable
    })
    

    然后,当你显示 json 时,使用 json 管道:

    {{fileContents | json}} 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-09-30
      • 1970-01-01
      • 2021-05-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多