简体   繁体   English

提取 html 标签并从字符串中制作数组

[英]Extract html tags and make array from string

I am building an Angular 9 app.我正在构建一个 Angular 9 应用程序。 In this app, the user can add HTML to a post.在这个应用程序中,用户可以将 HTML 添加到帖子中。 I want to take call instances of Blockquote and make an array of them.我想调用 Blockquote 的实例并制作它们的数组。 I also need to be able to access the title attribute and the content of the blockquote.我还需要能够访问标题属性和块引用的内容。 I am trying to build an automatic tab functionality.我正在尝试构建一个自动选项卡功能。

    <blockquote title="tab 1">
    Inner HTML
    </blockquote>

<blockquote title="tab 2">
    Inner HTML
    </blockquote>

for the title, you could bind to the attribute .对于标题,您可以绑定到属性

The same should go for innerHTML attribute binding .对于innerHTML属性绑定,go 也应如此。

Your example would then be你的例子将是

<blockquote [title]="tab 2" [innerHTML]="Inner HTML">
</blockquote>

and controlled by a component.并由一个组件控制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM