我想在我的應用程序組件中使用google漂亮打印來顯示源代碼。我在'pre'標記中使用ngNonBindable。但它在編譯/頁面運行時會出錯。ngNonBindable不能在angular-2中工作
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 ->]"): [email protected]:6
Invalid ICU message. Missing '}'. ("
<div id="routerContainer">
<router-outlet></router-outlet>
</div>[ERROR ->]"): [email protected]: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>
你爲什麼在'pre'標籤中使用import語句? 'ngNonBindable'告訴angular2不要評估任何表達式或綁定。 – micronyks
@micrnyks,我在我的網頁中顯示整個.ts源代碼。它僅用於顯示目的而不是用於解析目的。它是一個angular2錯誤,它解析{}儘管ngNonBindable。 – raju