在HTML angularjs中显示字符串

时间:2014-06-02 16:52:07

标签: javascript html angularjs

我想在HTML页面中显示一个长字符串的日志。我要显示的示例日志如下。当我将其直接插入HTML时,它将显示为连续文本。是否有更清晰的方式显示日志,因为它在我的屏幕上。实现的方法之一是用\n替换<br>,但仍然会删除大量的格式,如空格等。在angularjs中是否有任何内置方式或者我可以用来保存某种模块格式和显示原样?

Testrun log : org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"link text","selector":"python Button sub components"}
Command duration or timeout: 62.06 seconds
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:595)

1 个答案:

答案 0 :(得分:4)

您可以将其包装在<pre>标记中,以保留换行符和间距吗?

<pre>{{ logDataVar }}</pre>