【问题标题】:How can i load static html through a component in angular?如何通过角度组件加载静态html?
【发布时间】:2020-02-25 10:14:33
【问题描述】:

我有一个静态 html 列表,并希望在单击文本 href 时通过 angular 4 中的组件呈现它。

【问题讨论】:

  • 我投了反对票,因为您没有包含任何代码,或者似乎在尝试。
  • 非常好的问题

标签: javascript html angular


【解决方案1】:

您的组件应如下所示:

<your-component [yourInput]="yourHTML"> </your-component>

您的组件的 html 将如下所示:

<div [innerHTML]="yourInput"></div>

文档here

如果你有一个 html 列表,那么你应该使用 *ngFor 循环来显示它们。

【讨论】:

  • 我使用了 angular-cli.json 并将这些 html 添加到其中,然后使用 href 渲染它并且它起作用了。
  • “assets”:[“assets”,“favicon.ico”,“info.html”,“assets/howToHtml/0001_htg_introduction.html”,“assets/howToHtml/0002_htg_list.html”],
猜你喜欢
  • 2022-01-04
  • 1970-01-01
  • 1970-01-01
  • 2017-07-19
  • 2017-05-06
  • 2017-10-10
  • 1970-01-01
  • 1970-01-01
  • 2021-08-06
相关资源
最近更新 更多