移动项目文件后模态出错

问题描述 投票:0回答:1

在我移动了很少的项目文件后,我的nativescript项目中的模态有问题,包括模态。我重写了进口。我还删除了任何已编译的js文件,以便它可以正确地重新编译我的项目。

我真的不知道错误意味着什么,但它与模态显示函数有关,它返回模态设置值的promise。

应用/组件/注册/ 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() {

    }
}

问题在于this.modal.showModal()函数中的pickDate(),它是从注册页面调用的。

应用程序/共享/组件/模态/日期选择器/ 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
    }
}

这是模态本身最重要的是传递模态设定值的close()函数。

错误

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
    at ZoneDelegate.invoke (file:///data/data/org.nativescript.secura/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:388:26)
    at Object.onInvoke (file:///data/data/org.nativescript.secura/files/app/tns_modules/@angular/core/bundles/core.umd.js:3841:33)
    at ZoneDelegate.invoke (file:///data/data/org.nativescript.secura/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:387:32)
    at Zone.run (file:///data/data/org.nativescript.secura/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:138:43)
    at file:///data/data/org.nativescript.secura/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:883:34
    at ZoneDelegate.invokeTask (file:///data/data/org.nativescript.secura/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:421:31)
    at Object.onInvokeTask (file:///data/data/org.nativescript.secura/files/app/tns_modules/@angular/core/bundles/core.umd.js:3832:33)
    at ZoneDelegate.invokeTask (file:///data/data/org.nativescript.secura/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:420:36)
    at Zone.runTask (file:///data/data/org.nativescript.secura/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:188:47)
    at drainMicroTaskQueue (file:///data/data/org.nativescript.secura/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:595:35)
    at ZoneTask.invokeTask (file:///data/data/org.nativescript.secura/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:500:21)
    at ZoneTask.invoke (file:///data/data/org.nativescript.secura/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:485:48)
    at timer (file:///data/data/org.nativescript.secura/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:1561:29)
    at invoke (file:///data/data/org.nativescript.secura/files/app/tns_modules/tns-core-modules/timer/timer.js:19:48)

如果有人能帮助我,我会很高兴我花了很多时间在这上面。

angular typescript android-emulator nativescript angular2-nativescript
1个回答
0
投票

迁移到最新版本的angular(> = 7)和nativescript(> = 5)后,我遇到了同样的问题。在DatepickerModalComponent的模板中确定他有这个组件:

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

因此,删除已注册的选择器date-picker将解决问题。

尝试改变:

selector: "date-picker"

selector: "my-prefix-date-picker"
© www.soinside.com 2019 - 2024. All rights reserved.