diff --git a/src/positioning/positioning.service.ts b/src/positioning/positioning.service.ts index ec671ca022..77176964a6 100644 --- a/src/positioning/positioning.service.ts +++ b/src/positioning/positioning.service.ts @@ -1,4 +1,5 @@ import { Injectable, ElementRef, RendererFactory2, Inject, PLATFORM_ID, NgZone } from '@angular/core'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { isPlatformBrowser } from '@angular/common'; import { positionElements } from './ng-positioning'; @@ -6,7 +7,6 @@ import { positionElements } from './ng-positioning'; import { fromEvent, merge, of, animationFrameScheduler, Subject, Observable } from 'rxjs'; import { Options } from './models'; - export interface PositioningOptions { /** The DOM element, ElementRef, or a selector string of an element which will be moved */ element?: HTMLElement | ElementRef | string; @@ -64,7 +64,7 @@ export class PositioningService { this.update$$ ); - this.triggerEvent$.subscribe(() => { + this.triggerEvent$.pipe(takeUntilDestroyed()).subscribe(() => { if (this.isDisabled) { return; }