如何显示包含HTML <pre> or <code> tag?

时间:2017-03-17 22:02:21

标签: javascript angularjs html5

Any hint about this? I googled quite a bit but didn't find anything yet..

This code is showing me the variable name instead the code I stored there:

<pre class="prettyprint">{{::data.template}}</pre>

Thanks in advance.

1 个答案:

答案 0 :(得分:2)

在Angular 1&amp; 2你应该只能使用汉德尔条;

<pre class="prettyprint">{{data.template}}</pre>

您还可以绑定数据

Angular 1:

<pre class="prettyprint" ng-bind="data.template"></pre>

Angular 2:

<pre class="prettyprint" [innerText]="data.template"></pre>

您可以在此处找到有关绑定的更多信息 - https://www.themarketingtechnologist.co/introduction-to-data-binding-in-angular-2-versus-angular-1/