Angular 在[innerHTML]中包装时,角度跳过(不显示)内容
我有来自api调用的数据,格式如下: 数据格式Angular 在[innerHTML]中包装时,角度跳过(不显示)内容,angular,angular7,innerhtml,Angular,Angular7,Innerhtml,我有来自api调用的数据,格式如下: 数据格式 data { info:"Disable terminal line access for un-authorized outoging connections using the command<br><br>line [vty/console/aux] <beg line number> <end line number><br> transport output none&
data {
info:"Disable terminal line access for un-authorized outoging connections using the command<br><br>line [vty/console/aux] <beg line number> <end line number><br> transport output none<br>
}
如果您有任何建议,我们将不胜感激。只需转义数据即可{
信息:“使用命令[vty/console/aux]禁用未授权输出连接的终端线路访问
传输输出无
}
在模板中:
<ng-template #info let-item="celldata">
<div>{{data.info}}</div>
</ng-template>
{{data.info}
跳过它们是什么意思?不显示它们?这些标记是什么意思?是的,不显示它们,我认为innerHTML假设它们是自定义标记并跳过它们(不显示)。这是来自后端api调用的我的信息,我希望它按原样显示。如果数据是文本,为什么要将其显示为HTML?HTML解析认为它们是标记,因此尝试显示它们,但显然失败。与其使用
试试使用
和
@plopy,他很可能想要
解析为有效的html,但不解析为其他html。正如我在问题中告诉你的,这是后端数据,我无法修改。我只能在前端渲染。无法访问后端服务器代码是一件事,不知道如何在前端修改是另一件事。这是对你的问题的有效答案。这将显示其他HTML标签这也不会呈现标签。请阅读我的问题和讨论。顺便感谢您的回答。其呈现
标签的工作演示查看此链接:您需要删除表达式中类似{{data.info}的[innerHTML]用法。
data = {
info:
"Disable terminal line access for un-authorized outoging connections using the command<br><br>line [vty/console/aux] <beg line number> <end line number><br> transport output none<br>"
};
data {
info:"Disable terminal line access for un-authorized outoging connections using the command<br><br>line [vty/console/aux] <beg line number> <end line number><br> transport output none<br>
}
<ng-template #info let-item="celldata">
<div>{{data.info}}</div>
</ng-template>