ngNonBindable无法在angular-2中工作

时间:2016-11-06 09:38:59

标签: angular

我想在我的应用组件中使用google pretty print显示源代码。我正在使用ngNonBindable' pre'标签。但它在编译/页面运行时会出错。

zone.js:388Unhandled Promise rejection: Template parse errors:
Unexpected character "EOF" (Do you have an unescaped "{" in your template? Use "{{ '{' }}") to escape it.) ("
<div id="routerContainer">
    <router-outlet></router-outlet>
</div>[ERROR ->]"): AppComponent@37:6
Invalid ICU message. Missing '}'. ("
<div id="routerContainer">
    <router-outlet></router-outlet>
</div>[ERROR ->]"): AppComponent@37:6 ; Zone: <root> ; Task: Promise.then ; Value: Error: Template parse errors:(…) Error: Template parse errors:
Unexpected character "EOF" (Do you have an unescaped "{" in your template? Use "{{ '{' }}") to escape it.) ("

我的HTML代码是

<pre class="prettyprint"  ngNonBindable>
    import {Component} from '@angular/core';                                    
</pre>

1 个答案:

答案 0 :(得分:3)

在此处查看演示:https://plnkr.co/edit/PPChFemU6HnXDBQohIsj?p=preview

要显示innerText代码,您可以使用 .ts 来显示您想要的内容。

DomSanitizer
相关问题