The Angular documentation says
ngOnDestroy(): Cleanup just before Angular destroys the directive/component. Unsubscribe Observables and detach event handlers to avoid memory leaks. Called just before Angular destroys the directive/component.
Some developers are saying that the component properties (class variables) should also be set to null to avoid memory leaks. Is this true?
export class TestComponent implements OnInit, OnDestroy {
public name: string;
constructor() { }
ngOnInit() {
this.name = 'John';
}
ngOnDestroy() {
// is this code really necessary.
this.name = null;
}
}