Implement this interface to get notified when your component's view has been fully initialized.
Example
@Component(selector: 'child-cmp', template: '{{where}} child')
class ChildComponent {
@Input()
String where;
}
@Component(
selector: 'parent-cmp',
template: '<child-cmp where="view"></child-cmp>',
directives: const [ChildComponent]
)
class ParentComponent implements AfterViewInit {
@ViewChild(ChildComponent)
ChildComponentviewChild;
ParentComponent() {
// viewChild is not initialized yet
print(_message(viewChild));
}
@override
ngAfterViewInit() {
// viewChild is updated after the view has been initialized
console.log('ngAfterViewInit: ' + _message(viewChild));
}
String _message(cmp: ChildComponent) =>
cmp == null ? 'no child' : '${cmp.where} child';
}
@Component(
selector: 'app',
template: '<parent-cmp></parent-cmp>',
directives: const [ParentComponent]
)
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
-
ngAfterViewInit(
) → 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