我可以防止在我的预标签中插入换行吗?

时间:2022-04-07 10:24:54

One of my Angular views is a <pre> where my model data is rendered as preformatted text to send in an email, like this:

我的一个角度视图是

,其中我的模型数据呈现为预格式化文本,以发送电子邮件,如下所示:

<pre>Hello {{name}},
Thank you for your order of
<div ng-repeat="item in orders | filter:{include: true}">Item: {{item.name}}</div>
Sincerely yours
</pre>

My problem is that the HTML generated by Angular inserts comments followed by newlines which messes up the layout of the email text, like this:

我的问题是,角插入注释生成的HTML后面跟着新行,这会打乱电子邮件文本的布局,如下所示:

<!-- ngRepeat: item in orders | filter:{include: true} -->

Is there any way I can keep Angular from doing that?

有什么方法可以避免角?

1 个解决方案

#1


2  

You can't remove it, similar question here

你不能删除它,类似的问题

But you might solve it with CSS.

但是你可以用CSS来解决它。

.parent-of-pre{
    font-size:0;
}

pre{
    font-size:1rem;
}

#1


2  

You can't remove it, similar question here

你不能删除它,类似的问题

But you might solve it with CSS.

但是你可以用CSS来解决它。

.parent-of-pre{
    font-size:0;
}

pre{
    font-size:1rem;
}