An issue occurred in the modal window following the relocation of project files

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.

Answer №1

After upgrading to the latest version of angular (>=7) and nativescript (>=5), I encountered a similar issue. It seems that the DatepickerModalComponent's template contains the following component:

 <DatePicker (loaded)="onDatePickerLoaded($event)"></DatePicker>

To resolve the problem, you can remove the selector date-picker if it is already registered.

Instead of:

selector: "date-picker"

You can try changing it to:

selector: "my-prefix-date-picker"

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best approach to incorporate Column Reordering in react-data-grid?

Within my REACT application, I have incorporated the npm package react-data-grid. They offer a sample showcasing Column Reordering on their website. I wish to replicate this functionality in my own code. Upon reviewing their source code, I am puzzled abou ...

Using Angular frontend to access Django Admin

Is it possible to integrate Django admin with an Angular frontend? I'm currently using Angular version 8.0 for the frontend and Django for the backend. In my urls.py file, I have added the admin as shown below: from django.urls import path, re_path f ...

The typescript MenuProvider for react-native-popup-menu offers a range of IntrinsicAttributes

Looking to implement drop-down options within a Flatlist component, I've utilized the React Native Popup Menu and declared MenuProvider as the entry point in App.tsx. Encountering the following error: Error: Type '{ children: Element[]; }' ...

What is the process for declaring a module in order to perform named imports?

Currently, I am utilizing graphql-tag in my project. The structure of my files is as follows: ./operation.graphql Query User { ... } ./test.ts import { User } from './operation.graphql'; /// Module ''*.graphql'' has no ...

Using Observables for Polling in Angular 8

Greetings, I am in the process of upgrading my project from Angular 5 to Angular 8. Below is the code snippet I used for polling: Observable.interval(this.intervalTime).timeout(600000) .takeWhile(() => this.alive) .subs ...

What is the best method to retrieve HTTP headers from the backend and simultaneously send HTTP parameters to it in ASP.NET Core and Angular?

I am currently working with Angular 15 and ASP.NET Core 5. The backend retrieves paged items based on the parameters pageSize and pageIndex. Once the action method receives the pageSize and pageIndex parameters, it sends both the paged items and the total ...

Unable to set a union key type for dynamic objects

Within my object, I am dynamically assigning a field and its corresponding value: type PhoneFields = 'deliveryPhoneNumber' | 'pickupPhoneNumber' (props: { phoneField?: PhoneFields }) { const initialValues = { [props.phoneField ...

Retrieving values from objects using Typescript

I am facing an issue while trying to retrieve a value from an object. The key I need to use belongs to another object. Screenshot 1 Screenshot 2 However, when working with Typescript, I encounter the following error message. Error in Visual Studio Is ...

Error relating to Power bi date filter

Having trouble with the Power BI date slicer displaying calendar month/days in a language other than English, appearing like Spanish. After publishing to app.powerbi.com (dashboard), the report displays correctly in English. Similarly, on Local Power BI ...

Encountering difficulty creating a new entity in NestJS with TypeORM due to the error message EntityMetadataNotFoundError

Hey, I've been encountering some issues with TypeORM. I'm attempting to add a new entity to my current project and here's what I did: I created a new entity import { Entity, Column, PrimaryGeneratedColumn, JoinColumn, OneToOne } from ' ...

What is the process for connecting a form to a model in Angular 6 using reactive forms?

In the time before angular 6, my approach involved utilizing [(ngModel)] to establish a direct binding between my form field and the model. However, this method is now considered deprecated (unusable with reactive forms) and I find myself at a loss on how ...

Encountering an error message stating "Unsupported file format" when attempting to upload an Excel file to Azure Data

I am currently working on a project that involves user file input in an application using angular7 and .net core. The payload is sent to the backend through a websocket. Although I have successfully uploaded files to azure datalake, there seems to be an is ...

Demonstrate HTML and CSS integration through the use of the http.get method

In an attempt to create an iframe-like solution, I am using an http.get call to retrieve a site as an object containing HTML and CSS. The issue arises when using <link> tags because the CSS path is obtained from an external source, causing the HTML t ...

Despite using Enzyme to locate a component again, the expected prop value is still not being returned

Two components are involved here - a modal and a button that is meant to open the modal by setting its isOpen prop to true. The initial state of the modal is set to false, but when the button is clicked, it should change to true. While everything works fi ...

Automatically forwarding to another page in Angular 4 due to idle time

Is it possible to implement a timeout feature for inactivity on a webpage? For example, if a user is idle for 20 seconds without interacting with the page, can we automatically redirect them to the home screen? I've been struggling to get this functi ...

Unable to retrieve device UUID using capacitor/device on Android

I'm currently attempting to obtain the UUID of my devices so that I can send targeted notifications via Firebase. My front end and back end are connected, enabling the back end to send notifications to the front end using Firebase. However, all I am a ...

Automated Validation Grouping in Angular Reactive Forms Based on Control Properties

After implementing the following code block, I am uncertain if this is the correct behavior: this.formGroup = this.fb.group({ name: this.fb.group({ firstName: ['', Validators.required], lastName: ['', Validators.required] ...

Guide on uploading an Excel XLSX file to a Python Flask API using Angular 2

Is there a way to upload an Excel .xlsx file from Angular2 to Python Flask? I am able to upload the file, but when I try to open it, the content cannot be read. Here is the HTML for the upload dialog: <mat-form-field> <input matInput placeh ...

What is the best way to prevent a font awesome icon from appearing in a span during data loading

I am currently working on an Angular 11 application where I have implemented an icon to trigger the loading of a graph. However, I have noticed that there is a delay in loading the graph when the icon is clicked. To prevent users from triggering the icon m ...

What is the reason behind the lag caused by setTimeout() in my application, while RxJS timer().subscribe(...) does not have the same

I am currently working on a component that "lazy loads" some comments every 100ms. However, I noticed that when I use setTimeout for this task, the performance of my application suffers significantly. Here is a snippet from the component: <div *ngFor ...