Implement to execute ngOnInit after the first change-detection completed.

ngOnInit is called right after the component or directive's data-bound properties have been checked for the first time, and before any of its children have been checked. It is normally only invoked once when the directive is instantiated:

@Component(
  selector: 'user-panel',
  directives: const [NgFor],
  template: r'''
    <li *ngFor="let user of users">
      {{user}}
    </li>
  ''',
)
class UserPanel implements OnInit {
  final RpcService _rpcService;

  List<String> users = const [];

  UserPanel(this._rpcService);

  @override
  ngOnInit() async {
    users = await _rpcService.getUsers();
  }
}

Warning: As part of crash detection AngularDart may execute ngOnInit a second time if part of the application threw an exception during change detection.

Constructors

OnInit()

Properties

hashCode → int
The hash code for this object. [...]
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited

Methods

ngOnInit() → dynamic
Executed after the first change detection run for a directive. [...]
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

Operators

operator ==(other) → bool
The equality operator. [...]
inherited