Multiple Hooks in Angular
You can set multiple hooks at the same time. Let's see how this is done using the two hooks we've already studied.
We import two interfaces:
app/user/user.component.tsimport { OnInit, OnDestroy } from '@angular/core';
Let's connect them to the class:
app/user/user.component.tsexport class UserComponent implements OnInit, OnDestroy {
}
Let's write our two hooks:
app/user/user.component.tsexport class UserComponent implements OnInit, OnDestroy {
constructor() {
console.log('constructor is started');
}
ngOnInit() {
console.log('onInit is applied');
}
ngOnDestroy() {
console.log('onDestroy is applied');
}
}
Задание 1
Test both hooks on the reactive condition if.
Задание 2
Test both hooks on the reactive loop.