From 5b63325e0b44500fa84ca8c8f639db61e33215f3 Mon Sep 17 00:00:00 2001 From: Wykks Date: Sun, 9 Sep 2018 16:07:32 +0200 Subject: [PATCH] fix(control): add safety check to ngOnDestroy ref #53 --- projects/ngx-mapbox-gl/src/lib/control/control.component.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/projects/ngx-mapbox-gl/src/lib/control/control.component.ts b/projects/ngx-mapbox-gl/src/lib/control/control.component.ts index c9c1213ce..9ec12ec65 100644 --- a/projects/ngx-mapbox-gl/src/lib/control/control.component.ts +++ b/projects/ngx-mapbox-gl/src/lib/control/control.component.ts @@ -56,6 +56,8 @@ export class ControlComponent implements OnDestroy, AfterContentInit { } ngOnDestroy() { - this.MapService.removeControl(this.control); + if (this.control) { + this.MapService.removeControl(this.control); + } } }