Skip to content

Instantly share code, notes, and snippets.

@gparlakov
Last active February 11, 2018 11:08
Show Gist options
  • Select an option

  • Save gparlakov/04909404e48daeec0e3de03fe538b2d8 to your computer and use it in GitHub Desktop.

Select an option

Save gparlakov/04909404e48daeec0e3de03fe538b2d8 to your computer and use it in GitHub Desktop.
ngOnDestroy service ng-gotchas 1
@Injectable()
export class TimeService implements OnDestroy {
// ... some useful stuff
ngOnDestroy(): void {
// ... some clean up logic
}
}
@NgModule({
...
providers: [TimeService],
...
})
export class AppModule { }
@Component({/*... omitted for brevity*/})
export class TimeWidgetComponent {
constructor(timeService: TimeService) {
// useful stuff using timeService
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment