Browse Source

refactor(theme-shared): add ModalService as provider to modal.component

pull/3697/head
mehmet-erim 6 years ago
parent
commit
c8f2711650
  1. 1
      npm/ng-packs/packages/theme-shared/src/lib/components/modal/modal.component.ts
  2. 8
      npm/ng-packs/packages/theme-shared/src/lib/services/modal.service.ts

1
npm/ng-packs/packages/theme-shared/src/lib/components/modal/modal.component.ts

@ -27,6 +27,7 @@ export type ModalSize = 'sm' | 'md' | 'lg' | 'xl';
templateUrl: './modal.component.html', templateUrl: './modal.component.html',
animations: [fadeAnimation], animations: [fadeAnimation],
styleUrls: ['./modal.component.scss'], styleUrls: ['./modal.component.scss'],
providers: [ModalService],
}) })
export class ModalComponent implements OnDestroy { export class ModalComponent implements OnDestroy {
@Input() @Input()

8
npm/ng-packs/packages/theme-shared/src/lib/services/modal.service.ts

@ -1,11 +1,11 @@
import { ContentProjectionService, PROJECTION_STRATEGY } from '@abp/ng.core'; import { ContentProjectionService, PROJECTION_STRATEGY } from '@abp/ng.core';
import { ComponentRef, Injectable, TemplateRef, ViewContainerRef } from '@angular/core'; import { ComponentRef, Injectable, TemplateRef, ViewContainerRef, OnDestroy } from '@angular/core';
import { ModalContainerComponent } from '../components/modal/modal-container.component'; import { ModalContainerComponent } from '../components/modal/modal-container.component';
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
}) })
export class ModalService { export class ModalService implements OnDestroy {
private containerComponentRef: ComponentRef<ModalContainerComponent>; private containerComponentRef: ComponentRef<ModalContainerComponent>;
constructor(private contentProjectionService: ContentProjectionService) { constructor(private contentProjectionService: ContentProjectionService) {
@ -44,4 +44,8 @@ export class ModalService {
this.contentProjectionService.projectContent(strategy); this.contentProjectionService.projectContent(strategy);
} }
ngOnDestroy() {
this.containerComponentRef.destroy();
}
} }

Loading…
Cancel
Save