Last active
February 11, 2018 11:08
-
-
Save gparlakov/04909404e48daeec0e3de03fe538b2d8 to your computer and use it in GitHub Desktop.
ngOnDestroy service ng-gotchas 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Injectable() | |
| export class TimeService implements OnDestroy { | |
| // ... some useful stuff | |
| ngOnDestroy(): void { | |
| // ... some clean up logic | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @NgModule({ | |
| ... | |
| providers: [TimeService], | |
| ... | |
| }) | |
| export class AppModule { } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @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