使用Angular 6将嵌套对象内部的数组更新为Firestore

时间:2019-01-02 07:08:51

标签: javascript angular object nested google-cloud-firestore

我有一个包含一个对象,一个数组和一些其他属性的对象,我可以使用[(ngModel)]访问它们。但是无法更新Customer对象和line_items数组内部的属性。

当我调用使用line_items获取的[(ngModel)]属性的更新时,会在line_items之外创建一个新属性,而不是属性更新。

P.S我在后端使用Firestore。

这是我的-

export class SalesOrders{
    Customer:{
        customercode:string;
        customername:string;
    };
    Remarks:string="";
    Totalamount:number=0;

    line_items:[
        {
            productname:string;
            quantity:string;
        }
    ];
}

脚本-

<input type="text" placeholder="Enter Customer Name" class="form-control" [(ngModel)]="ordersCollection.Customer.customername"
    name="customername">

<input type="text" class="form-control" [(ngModel)]="ordersCollection.Remarks" name="Remarks">

<div class="row" *ngFor="let item of ordersCollection.line_items;let i=index">
    <input type="text" class="form-control" [(ngModel)]="item.productname" name="productname" id="productname">
</div>

0 个答案:

没有答案
相关问题