Angular文档说
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.
一些开发人员说组件属性(类变量)也应该设置为null以避免内存泄漏.这是真的?
export class TestComponent implements OnInit,OnDestroy { public name: string; constructor() { } ngOnInit() { this.name = 'John'; } ngOnDestroy() { // is this code really necessary. this.name = null; } }