Skip to content

Commit

Permalink
perf(module: modal): perf modal service (#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
Guoyuanqiang authored and fisherspy committed Jan 7, 2019
1 parent 3fb41f1 commit 4fca40a
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
7 changes: 2 additions & 5 deletions components/core/services/popup.service.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import { Injectable, Injector, ViewContainerRef, ComponentRef } from '@angular/core';
import { Injectable, Injector, ComponentRef } from '@angular/core';
import { Overlay, OverlayConfig, OverlayRef, GlobalPositionStrategy } from '@angular/cdk/overlay';
import { ComponentPortal } from '@angular/cdk/portal';

@Injectable()
export class PopupService {
static viewContainerRef: ViewContainerRef = null;
static overlay: Overlay = null;
static overlayRef: OverlayRef = null;

constructor(
public _overlay: Overlay,
public _viewContainerRef: ViewContainerRef
) {
PopupService.viewContainerRef = this._viewContainerRef;
PopupService.overlay = this._overlay;
}

Expand All @@ -30,7 +27,7 @@ export class PopupService {
PopupService.overlayRef.dispose();
});

return PopupService.overlayRef.attach(new ComponentPortal(component, PopupService.viewContainerRef, childInjector));
return PopupService.overlayRef.attach(new ComponentPortal(component, undefined, childInjector));
}

static hidePopup(): void {
Expand Down
2 changes: 1 addition & 1 deletion components/modal/demo/alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { Modal, Toast } from 'ng-zorro-antd-mobile';
<WhiteSpace></WhiteSpace>
</WingBlank>
`,
providers: [Toast, Modal]
providers: [Toast]
})
export class DemoModalAlertComponent {
constructor(private _modal: Modal, private _toast: Toast) {}
Expand Down
2 changes: 1 addition & 1 deletion components/modal/demo/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import { Modal, Toast } from 'ng-zorro-antd-mobile';
}
`
],
providers: [Toast, Modal]
providers: [Toast]
})
export class DemoModalBasicComponent {
state = {
Expand Down
2 changes: 1 addition & 1 deletion components/modal/demo/operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Modal, Toast } from 'ng-zorro-antd-mobile';
<WhiteSpace></WhiteSpace>
</WingBlank>
`,
providers: [Toast, Modal]
providers: [Toast]
})
export class DemoModalOperationComponent {
constructor(private _modal: Modal, private _toast: Toast) {}
Expand Down
2 changes: 1 addition & 1 deletion components/modal/demo/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { Modal, Toast } from 'ng-zorro-antd-mobile';
<WhiteSpace></WhiteSpace>
</WingBlank>
`,
providers: [Toast, Modal]
providers: [Toast]
})
export class DemoModalPromptComponent {
constructor(private _modal: Modal, private _toast: Toast) {}
Expand Down
3 changes: 3 additions & 0 deletions components/modal/modal.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import {
import { ModalServiceComponent } from './modal.component';
import { BaseOptions, ModalOptions, AlertOptions, Action } from './modal-options.provider';
import { PopupService } from '../core/core.module';
@Injectable({
providedIn: 'root'
})
@Injectable()
export class Modal extends PopupService {
static modalRef: ComponentRef<ModalServiceComponent> = null;
Expand Down

0 comments on commit 4fca40a

Please sign in to comment.