Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/angular/src/lib/cdk/dialog/dialog-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { ViewContainerRef, ComponentFactoryResolver } from '@angular/core';
import { ShowModalOptions } from '@nativescript/core';
import { ShowModalOptions, View } from '@nativescript/core';

export type NativeShowModalOptions = Partial<Omit<ShowModalOptions, 'cancelable' | 'closeCallback'>>;
/**
Expand All @@ -22,6 +22,9 @@ export class NativeDialogConfig<D = any> {
*/
viewContainerRef?: ViewContainerRef;

/** Where to render the actual dialog in. By default it renders using the native view of the ViewContainerRef */
renderIn: 'root' | 'viewContainerRef' | View = 'viewContainerRef';

/** ID for the dialog. If omitted, a unique one will be generated. */
id?: string;

Expand Down
9 changes: 7 additions & 2 deletions packages/angular/src/lib/cdk/dialog/native-modal-ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ export class NativeModalRef {
private _closeCallback: () => void;
private _isDismissed = false;

constructor(private _config: NativeDialogConfig, private _injector: Injector, @Optional() private location?: NSLocationStrategy) {
let parentView = this._config.viewContainerRef?.element.nativeElement || Application.getRootView();
constructor(
private _config: NativeDialogConfig,
private _injector: Injector,
@Optional() private location?: NSLocationStrategy,
) {
const nativeElement = this._config.renderIn === 'root' ? Application.getRootView() : this._config.renderIn === 'viewContainerRef' ? this._config.viewContainerRef?.element.nativeElement : this._config.renderIn;
let parentView = nativeElement || Application.getRootView();

if ((parentView instanceof AppHostView || parentView instanceof AppHostAsyncView) && parentView.ngAppRoot) {
parentView = parentView.ngAppRoot;
Expand Down