I encountered an issue with the modal in my Nativescript project after rearranging a few project files, including the modal. I updated the imports and deleted any compiled JavaScript files to ensure that my project could recompile correctly.
Although I'm not exactly sure what the error message means, it seems to be related to the function responsible for displaying the modal and returning a promise for setting its value.
/app/components/register/register.component.ts
import { Component, ViewContainerRef } from "@angular/core";
import { AuthService } from "../../shared/services/auth.service";
import { ModalDialogService } from "nativescript-angular/directives/dialogs";
import { DatepickerModalComponent } from "../../shared/components/modals/datepicker/datepicker.modal.component";
@Component({
selector: "register",
moduleId: module.id,
templateUrl: "./register.component.html"
})
export class RegisterComponent {
private date;
constructor(private auth: AuthService, private modal: ModalDialogService, private ref: ViewContainerRef) {}
pickItem() {
}
pickDate() {
let opts = {
context: {},
fullscreen: false,
viewContainerRef: this.ref
}
this.modal.showModal(DatepickerModalComponent, opts).then(res => {
let pickerDate = res;
let dateString = pickerDate.toISOString().slice(0,10);
this.date = dateString;
});
}
submit() {
}
}
The issue appears to be within the this.modal.showModal()
function called in the pickDate()
method on the registration page.
/app/shared/components/modals/datepicker/datepicker.modal.component.ts
import { Component } from '@angular/core';
import { ModalDialogParams } from 'nativescript-angular/directives/dialogs';
@Component({
selector: "date-picker",
moduleId: module.id,
templateUrl: "./datepicker.modal.component.html"
})
export class DatepickerModalComponent {
private date;
constructor(private params: ModalDialogParams) {}
close() {
this.params.closeCallback(this.date);
}
onPickerLoaded() {
this.date = new Date();
}
onDateChanged(args) {
this.date = args.value
}
}
One crucial aspect of the modal is the close()
function, which sets the modal value upon closure.
Error Message
core.umd.js:1708 ERROR Error: Uncaught (in promise): TypeError: detachedProxy.getChildrenCount is not a function
TypeError: detachedProxy.getChildrenCount is not a function
at file:///data/data/org.nativescript.secura/files/app/tns_modules/nativescript-angular/directives/dialogs.js:82:31
...additional error details...
If someone could provide assistance, I would greatly appreciate it as I have invested considerable time attempting to resolve this issue.