当 ng-template 可见时调用方法

Mah*_*Gvp 6 ng-template angular

当 ng-template 在范围内可见或活动时,它是否有任何事件 ,或者是否可以以这种方式执行任何方法以从容器中调用它?

<ng-template (active/vissible)="callMethod()"> ... </ng-template>
Run Code Online (Sandbox Code Playgroud)

(或者)

<ng-container *ngTemplateOutlet="mytemplate" ></ng-container>
Run Code Online (Sandbox Code Playgroud)

小智 -1

您可以使用

public mycondition: boolean = true;   ///according to need make it true or false

<ng-template *ngIf="mycondition"> ... </ng-template>
Run Code Online (Sandbox Code Playgroud)