Skip to content

Commit 4d17a2e

Browse files
committed
fix: emit 'unmount'
1 parent 4032bfa commit 4d17a2e

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/ref.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { Input, ElementRef, OnChanges } from '@angular/core';
1+
import { Input, ElementRef, OnChanges, OnDestroy } from '@angular/core';
22
import { Directive } from '@angular/core';
33

44
@Directive({
55
selector: '[refComponent]'
66
})
7-
export class RefDirective implements OnChanges {
7+
export class RefDirective implements OnChanges, OnDestroy {
88
@Input() data!: any
99
@Input() emit!: any
1010

@@ -13,4 +13,8 @@ export class RefDirective implements OnChanges {
1313
ngOnChanges() {
1414
this.emit({ type: 'render', data: { ...this.data, element: this.el.nativeElement } })
1515
}
16+
17+
ngOnDestroy() {
18+
this.emit({ type: 'unmount', data: { element: this.el.nativeElement } })
19+
}
1620
}

0 commit comments

Comments
 (0)