【问题标题】:How to render html http response to a new page or a new component in Angular?如何在 Angular 中呈现对新页面或新组件的 html http 响应?
【发布时间】:2021-04-26 16:34:34
【问题描述】:

我想知道是否有一种方法可以在新页面或新组件中呈现 html 的 http 响应?具体问题如下所述。

调用后端的代码:

const headers = { 'content-type': 'application/x-www-form-urlencoded'}  
let obs = this.http.post<any>("http://localhost:8080/project/Raffle", _data,{ headers, responseType: 'text' as 'json'});
obs.subscribe((response)=>console.log(response));

响应是显示在控制台中的 html 页面。

<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Thank you for taking the survey! You win the raffle of two movie tickets!</title>
</head>
<body>
...
</body>
</html>

我的问题是如何将内容呈现在新组件中或可能呈现为新的 html 页面? 非常感谢!

【问题讨论】:

    标签: html angular rendering httpresponse


    【解决方案1】:

    您应该能够使用输出和 Handlebar.js 创建模板并将其显示为 html 页面。

    请参考此资源=>

    https://www.npmjs.com/package/handlebars

    https://handlebarsjs.com/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-02-25
      • 2015-05-08
      • 2020-01-05
      • 2018-03-21
      • 1970-01-01
      • 1970-01-01
      • 2020-07-11
      相关资源
      最近更新 更多