NgContentRef class

Represents a reference to an <ng-content> element.

This can be used to query whether an <ng-content> has any projected nodes. Users can access this class via a direct reference in the template, or a view query.

@Component(
  selector: 'comp',
  template: '''
    <ng-content #projectedContent></ng-content>
    <div *ngIf="!projectedContent.hasContent">
      There was no projected content. Here is some default content!
    </div>
  ''',
)
class FooComponent {
  @ViewChild(NgContentRef)
  NgContentRef child;
}

Constructors

NgContentRef(RenderView _renderView, int _index)

Properties

hasContent bool
Returns whether this has any projected nodes.
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited