Implement this interface to get notified when your directive's content has been fully initialized.
Example
@Component(
selector: 'child-cmp',
template: '{{where}} child'
)
class ChildComponent {
@Input()
String where;
}
@Component(
selector: 'parent-cmp',
template: '<ng-content></ng-content>'
)
class ParentComponent implements AfterContentInit {
@ContentChild(ChildComponent)
ChildComponent contentChild;;
ParentComponent() {
// contentChild is not initialized yet
print(_message(contentChild));
}
@override
ngAfterContentInit() {
// contentChild is updated after the content has been checked
console.log('AfterContentInit: ' + _message(contentChild));
}
String _message(ChildComponent cmp) =>
cmp == null ? 'no child' : '${cmp.where} child';
}
@Component(
selector: 'app',
template: '''
<parent-cmp>
<child-cmp where="content"></child-cmp>
</parent-cmp>
''',
directives: const [ParentComponent, ChildComponent]
)
export class App {}
bootstrap(App);
Constructors
Properties
- hashCode → int
-
Get a hash code for this object.
read-only, inherited - runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
Operators
-
operator ==(
other) → bool -
The equality operator.
inherited
Methods
-
ngAfterContentInit(
) → dynamic -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed.
inherited -
toString(
) → String -
Returns a string representation of this object.
inherited