Skip to content

Instantly share code, notes, and snippets.

@gparlakov
Last active February 11, 2018 12:00
Show Gist options
  • Save gparlakov/ebc9a64507dd025b80a3872db56a37b2 to your computer and use it in GitHub Desktop.
Save gparlakov/ebc9a64507dd025b80a3872db56a37b2 to your computer and use it in GitHub Desktop.
@Injectable()
export class TimeService implements OnDestroy {
// ... some useful stuff
ngOnDestroy(): void {
// ... some clean up logic
}
}
@Component({
providers: [
TimeService
]
})
export class FeedComponent {
constructor(timeService: TimeService) {
// useful stuff using timeService
}
}
@gparlakov
Copy link
Author

Service gets its ngOnDestroy called when component is destroyed. Even when it itself does not have the ngOnDestroy method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment