diff --git a/apps/nativescript-demo-ng/src/app/modal/modal.component.html b/apps/nativescript-demo-ng/src/app/modal/modal.component.html index 3619fe6..be7c93a 100644 --- a/apps/nativescript-demo-ng/src/app/modal/modal.component.html +++ b/apps/nativescript-demo-ng/src/app/modal/modal.component.html @@ -1,3 +1,4 @@ - - + + + diff --git a/apps/nativescript-demo-ng/src/app/modal/modal.component.ts b/apps/nativescript-demo-ng/src/app/modal/modal.component.ts index 937d07b..447bed9 100644 --- a/apps/nativescript-demo-ng/src/app/modal/modal.component.ts +++ b/apps/nativescript-demo-ng/src/app/modal/modal.component.ts @@ -1,14 +1,21 @@ -import { Component, Inject, Optional } from '@angular/core'; -import { NativeDialogRef } from '@nativescript/angular'; +import { Component, Inject, OnDestroy, OnInit, Optional, ViewContainerRef } from '@angular/core'; +import { ModalDialogService, NativeDialogRef, NativeDialogService } from '@nativescript/angular'; @Component({ selector: 'ns-modal', templateUrl: `./modal.component.html`, }) -export class ModalComponent { +export class ModalComponent implements OnInit, OnDestroy { id = Math.floor(Math.random() * 1000); - constructor(@Optional() ref: NativeDialogRef) {} + constructor(@Optional() private ref: NativeDialogRef, private nativeDialog: NativeDialogService, private modalDialog: ModalDialogService, private vcRef: ViewContainerRef) {} + + openNewModal() { + this.nativeDialog.open(ModalComponent); + // this.modalDialog.showModal(ModalComponent, { + // viewContainerRef: this.vcRef + // }); + } ngOnInit() { console.log('modal init'); } diff --git a/packages/angular/src/lib/legacy/directives/dialogs.ts b/packages/angular/src/lib/legacy/directives/dialogs.ts index 4ce2cda..7a6c690 100644 --- a/packages/angular/src/lib/legacy/directives/dialogs.ts +++ b/packages/angular/src/lib/legacy/directives/dialogs.ts @@ -140,7 +140,7 @@ export class ModalDialogService { ɵmarkDirty(componentRef.instance); componentViewRef = new NgViewRef(componentRef); if (componentViewRef !== componentRef.location.nativeElement) { - componentRef.location.nativeElement._ngDialogRoot = componentViewRef; + componentRef.location.nativeElement._ngDialogRoot = componentViewRef.firstNativeLikeView; } // if we don't detach the view from its parent, ios gets mad componentViewRef.detachNativeLikeView(); diff --git a/packages/angular/src/lib/views/utils.ts b/packages/angular/src/lib/views/utils.ts index 91b3c77..2041a62 100644 --- a/packages/angular/src/lib/views/utils.ts +++ b/packages/angular/src/lib/views/utils.ts @@ -29,9 +29,6 @@ export function getFirstNativeLikeView(view: View, extractFromNSParent = false) } return getFirstNativeLikeView(view.getChildAt(0)); } - if (isContentView(view)) { - return getFirstNativeLikeView(view.content); - } if (extractFromNSParent) { // const node = view.parentNode;