There is no good way to query for arbitrary projected content
@Component({
selector: 'item',
template: `
<div *ngIf="divider" class="divider"></div>
<div #wrapper><ng-content select=".nav-toggle"></ng-content></div>'})
class Item implements AfterContentInit {
@ViewChild('wrapper') wrapper:ElementRef;
divider:boolean = false;
ngAfterContentInit() {
console.log(this.wrapper.nativeElement.innerHTML); // or `wrapper.text`
this.divider = !!this.wrapper.nativeElement.children;
}
}
See also Access transcluded content
If you know the projected content is a specific Angular component or the element has a specific template variable applied, you can use @ContentChildren()
(see also angular 2 / typescript : get hold of an element in the template).