Closed scgy5555 closed 7 years ago
<ng-content select="[slot=modal-footer]"></ng-content>
<ng-template [ngIf]="!hasCustomFooter">
xxxxxxx
</ng-template>
this.hasCustomFooter = !!this.modalFooter.nativeElement.querySelector('[slot=modal-footer]');
这是一段标准的vue代码,想通过angular2实现相同的效果。 其功能是判断嵌入子元素是否存在。
翻了很多资料ng-content本身似乎没有这种变量。 使用ContentChild也只能用于#标记的ElementRef。
有没有办法在不指定嵌入子元素类型(Class)的时候判断嵌入子元素是否存在。 学艺不精,或许思路就有问题,还请大大指点。