我有2个Spring Boot应用程序,需要在这两个应用程序之间进行通信。我有休息模板可以交流。除了休息模板以外,还有其他交流技巧吗?
我正在使用ngTemplateOutlet加载。但是它会多次加载模板。正在加载正确的模板,但会多次执行loadTemplate()方法。
在HTML中:
<table>
<thead>
</thead>
<tbody>
<ng-template [ngTemplateOutlet]="loadTemplate()"></ng-template>
</tbody>
</table>
<ng-template #template1>
<tr *ngFor="iteration">
<p>Hiii</p>
</tr>
</ng-template>
<ng-template #template2>
<tr *ngFor="iteration">
<p>Byee</p>
</tr>
</ng-template>
Run Code Online (Sandbox Code Playgroud)
在我的component.ts中:
@ViewChild('template1') template1: TemplateRef<any>;
@ViewChild('template1') template1: TemplateRef<any>;
loadTemplate(){
if (condition)
return this.template1;
return this.template2;
}
Run Code Online (Sandbox Code Playgroud)