首页 > 解决方案 > 组织结构图没有转义变量 - Angular 7

问题描述

使用 PrimeNG 高级组织结构图:https ://www.primefaces.org/primeng/#/organizationchart

统计数据:Angular 7 Chrome 浏览器:当前版本

错误:

    compiler.js:2430 Uncaught Error: Template parse errors:
Unexpected character "EOF" (Do you have an unescaped "{" in your template? Use "{{ '{' }}") to escape it.) ("
    </ng-template>
</p-organizationChart>
</div>[ERROR ->]"): ng:///AppModule/OrdertreeComponent.html@16:6
Unexpected closing tag "ng-template". It may happen when the tag has already been closed by another tag. For more info see https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags ("
            <div>{{node.data.name}}</div>
        </div>
    [ERROR ->]</ng-template>
    <ng-template let-node pTemplate="department">
      { { node.label } }
"): ng:///AppModule/OrdertreeComponent.html@11:4
Invalid ICU message. Missing '}'. ("
    </ng-template>

html:

    <p>Organization with advanced customization.</p>
<p-organizationChart [value]="data1" selectionMode="single" [(selection)]="selectedNode" (onNodeSelect)="onNodeSelect($event)" styleClass="company">
      <ng-template let-node pTemplate="person">
     <div class="node-header ui-corner-top">{{node.label}}/div>
        <div class="node-content">
            <img src="assets/showcase/images/demo/organization/{node.data.avatar}" width="32">
            <div>{{node.data.name}}</div>
        </div>
    </ng-template>
    <ng-template let-node pTemplate="department">
      { { node.label } }
    </ng-template>
</p-organizationChart>

尝试修复:

我尝试对括号使用不同类型的转义方法,但似乎没有任何效果。我找不到任何使用 Angular 7 改变的东西。

标签: primengangular7

解决方案


将单花括号更改为双花括号为我解决了这个问题。


推荐阅读