Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 当我更新时,信息消失了_Javascript_Html_Angular_Typescript - Fatal编程技术网

Javascript 当我更新时,信息消失了

Javascript 当我更新时,信息消失了,javascript,html,angular,typescript,Javascript,Html,Angular,Typescript,我正在编写一个代码,用户可以在其中更新一些数据。当用户第一次保存信息时,屏幕上的信息消失。然后,当我第二次单击编辑按钮时,编辑对话框没有打开,我得到下面的错误。有什么问题吗? 下面是编辑对话框组件的HTML和TS的一个小片段: <div fxLayout="row" fxLayoutAlign="start center"> <mat-form-field appearance="outline

我正在编写一个代码,用户可以在其中更新一些数据。当用户第一次保存信息时,屏幕上的信息消失。然后,当我第二次单击编辑按钮时,编辑对话框没有打开,我得到下面的错误。有什么问题吗?

下面是编辑对话框组件的HTML和TS的一个小片段:

<div fxLayout="row" fxLayoutAlign="start center">
                <mat-form-field appearance="outline" fxFlex="100" fxFlex.gt-xs="40" class="w-100-p pr-8">
                    <mat-label>Receipt Code</mat-label>
                    <input matInput formControlName="StockIntegrationCode" type="number">
                </mat-form-field>
                <mat-form-field appearance="outline" fxFlex="100" fxFlex.gt-xs="40" class="w-100-p pr-8">
                    <mat-label>Receipt Name</mat-label>
                    <input matInput formControlName="Name" type="text">
                </mat-form-field>
            </div>
        <button mat-stroked-button class="amber-fg pr-4" (click)="save($event)"> Kaydet</button>

你能把你的代码贴在你声明的
setReceiptItems
method/setter的地方吗?错误表明您正在尝试将属性添加到布尔值。我编辑了postNow,显示了您声明
receipt
组件成员(this.receipt)的部分。在
this.receipt.packagingereipts=receipts行之前,也将其记录到控制台您可能会在那里得到一个布尔值,而不是您所期望的值。除此之外,您还可以将循环替换为
let receipts:irecept[]=this.dataSource2.data.map(d=>{return d.receiptas irecept})
也许您的问题在于
这一点。\u dialogRef.close(true)尝试
此操作。_dialogRef.close(响应)只是在黑暗中射击谢谢你,你是对的问题是
这个
save(e) {
        e.preventDefault();
        if (this.form.valid) {
            this.receipt.Name = this.form.controls["Name"].value;
            this.receipt.ReceiptType.Id = this.form.controls[
                "ReceiptType"
            ].value;
            this.receipt.ReceiptGroupType.Id = this.form.controls["ReceiptGroupType"].value;
            this.receipt.StockIntegrationCode = this.form.controls[
                "StockIntegrationCode"
            ].value;

this.confirmDialogRef.componentInstance.confirmMessage =
                "Receipt will be changed, are you sure?";

            this.confirmDialogRef.afterClosed().subscribe((result) => {
                if (result) {
                    this._productionService
                        .saveAndGetReceipt(this.receipt)
                        .subscribe((response: IReceipt) => {
                            this.receipt = response;
                            this._messages.Show(
                                "Receipt is updated",
                                "SUCCESS",
                                3
                            );
                            this._dialogRef.close(true);
                        });
                }
            });





setReceiptItems() {
        let receipts: IReceipt[] = [];
        for (let d of this.dataSource2.data) {
            receipts.push(d.Receipt);
        }

        let receiptItems: IReceiptItem[] = [];
        for (let d of this.dataSource1.data) {
            receiptItems.push(d);
        }
        for (let d of this.dataSourceMuadil.data) {
            receiptItems.push(d);
        }

        let receiptTerms: IReceiptTerm[] = [];
        for (let d of this.dataSourceTerm.data) {
            receiptTerms.push(d);
        }

        this.receipt.PackagingReceipts = receipts;
        this.receipt.ReceiptItems = receiptItems;
        this.receipt.ReceiptTerms = receiptTerms;
    }