示例代码
<p-accordion *ngIf="cat" (onOpen)="openTabAccordion($event)" [ngClass]="{'p-accordion':true}">
<p-accordionTab *ngFor="let item of cat;let i = index" [header]="item.data.name">
<div *ngIf="results; else loading">
<p-listbox *ngIf="results.length > 0; else not_data" [style]="{'width':'100%','max-height':'250px'}"
[options]="results"
[(ngModel)]="currentP" (onChange)="selectedP($event);">
<ng-template let-p pTemplate="item">
<app-p-i [prop]="p.value"></app-p-i>
</ng-template>
</p-listbox>
<ng-template #not_data>
Not Record Found
</ng-template>
</div>
<ng-template #loading>loading ...</ng-template>
</p-accordionTab>
</p-accordion>
组件app-p-i我希望它只在当前的accordionTab中调用,但是当调试app-p-i时,它会创建很多实例,以便accordionTab具有p-accordion。
如何限制组件的创建只打开accordionTab,可以或者我已定义每个accordionTab显式