2017-08-04 6 views
0

ng-templateで定義されたhtmlのブロックを直接参照する方法は?ng-templateで定義されたhtmlのブロックを角度で直接参照する方法は?

filterOfDivを参照するには、*ngIfディレクティブを使用し、常に条件をtrueに設定する必要があります。

<ng-container *ngIf='true; then filterOfDiv'></ng-container> 
<ng-template #filterOfDiv> 
    <div class="flex-column row-space filter-container"> 
    <div> 
     <input type="checkbox" id="company1"><label for="company1" class="label-input">company1</label> 
    </div> 
    <div> 
     <input type="checkbox" id="company2"><label for="company2" class="label-input">company2</label> 
    </div> 
    </div> 
</ng-template> 

のように、直接filterOfDivを参照する方法があります:

<ng-container filterOfDiv></ng-container> 

答えて

1

ちょうど使用NgTemplateOutletディレクティブ

<ng-container *ngTemplateOutlet="filterOfDiv"></ng-container> 
関連する問題