mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(angular): create angular delegate
This commit is contained in:
@@ -69,6 +69,11 @@ import { ToastController } from './providers/toast-controller';
|
||||
VirtualHeader,
|
||||
VirtualFooter
|
||||
],
|
||||
providers: [
|
||||
AngularDelegate,
|
||||
ModalController,
|
||||
PopoverController,
|
||||
],
|
||||
imports: [
|
||||
CommonModule,
|
||||
],
|
||||
@@ -81,9 +86,6 @@ export class IonicAngularModule {
|
||||
return {
|
||||
ngModule: IonicAngularModule,
|
||||
providers: [
|
||||
ModalController,
|
||||
PopoverController,
|
||||
AngularDelegate,
|
||||
AlertController,
|
||||
ActionSheetController,
|
||||
Events,
|
||||
|
||||
@@ -9,7 +9,19 @@ import { FrameworkDelegate } from '@ionic/core';
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class AngularDelegate implements FrameworkDelegate {
|
||||
export class AngularDelegate {
|
||||
|
||||
constructor(
|
||||
private appRef: ApplicationRef
|
||||
) {}
|
||||
|
||||
create(cfr: ComponentFactoryResolver, injector: Injector) {
|
||||
return new AngularFrameworkDelegate(cfr, injector, this.appRef);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class AngularFrameworkDelegate implements FrameworkDelegate {
|
||||
|
||||
private elRefMap = new WeakMap<HTMLElement, any>();
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ComponentFactoryResolver, Injectable, Injector } from '@angular/core';
|
||||
import { ModalOptions } from '@ionic/core';
|
||||
import { OverlayBaseController } from '../util/overlay';
|
||||
import { AngularDelegate } from './angular-delegate';
|
||||
@@ -6,6 +6,8 @@ import { AngularDelegate } from './angular-delegate';
|
||||
@Injectable()
|
||||
export class ModalController extends OverlayBaseController<ModalOptions, HTMLIonModalElement> {
|
||||
constructor(
|
||||
private cfr: ComponentFactoryResolver,
|
||||
private injector: Injector,
|
||||
private angularDelegate: AngularDelegate,
|
||||
) {
|
||||
super('ion-modal-controller');
|
||||
@@ -14,7 +16,7 @@ export class ModalController extends OverlayBaseController<ModalOptions, HTMLIon
|
||||
create(opts?: ModalOptions): Promise<HTMLIonModalElement> {
|
||||
return super.create({
|
||||
...opts,
|
||||
delegate: this.angularDelegate
|
||||
delegate: this.angularDelegate.create(this.cfr, this.injector)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,22 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ComponentFactoryResolver, Injectable, Injector } from '@angular/core';
|
||||
import { PopoverOptions } from '@ionic/core';
|
||||
import { OverlayBaseController } from '../util/overlay';
|
||||
import { AngularDelegate } from './angular-delegate';
|
||||
|
||||
@Injectable()
|
||||
export class PopoverController extends OverlayBaseController<PopoverOptions, HTMLIonPopoverElement> {
|
||||
constructor() {
|
||||
constructor(
|
||||
private cfr: ComponentFactoryResolver,
|
||||
private injector: Injector,
|
||||
private angularDelegate: AngularDelegate,
|
||||
) {
|
||||
super('ion-popover-controller');
|
||||
}
|
||||
|
||||
create(opts?: PopoverOptions): Promise<HTMLIonPopoverElement> {
|
||||
return super.create({
|
||||
...opts,
|
||||
delegate: this.angularDelegate.create(this.cfr, this.injector)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,6 @@ import { OverlayBaseController } from '../util/overlay';
|
||||
@Injectable()
|
||||
export class ToastController extends OverlayBaseController<ToastOptions, HTMLIonToastElement> {
|
||||
constructor() {
|
||||
super('ion-popover-controller');
|
||||
super('ion-toast-controller');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user