移动项目文件后出现模态错误

时间:2018-07-06 20:28:22

标签: angular typescript android-emulator nativescript angular2-nativescript

在我移动了一些项目文件(包括模式)后,我的nativescript项目中的模式出现了问题。我重写了进口。我还删除了所有已编译的js文件,以便它可以正确地重新编译我的项目。

我真的不知道错误的含义,但它与模式显示函数有关,该函数返回模式设定值的承诺。

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() {

    }
}

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

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
    }
}

模态本身是最重要的,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)

如果有人可以帮助我,我为此花了很多时间,我会非常高兴。

1 个答案:

答案 0 :(得分:0)

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

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

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

尝试从以下位置更改

selector: "date-picker"

selector: "my-prefix-date-picker"