Angular Firestore如何将数据保存为数组

时间:2019-06-14 12:42:20

标签: javascript angular google-cloud-firestore

我想知道如何将数据存储在Firestore中作为数组。我的意思是:从用户那里获取3个输入并将3个输入保存在数组的1个字段中。

在这里我想显示5到6个输入框,并将数据保存在设施数组中保存的框中。

      <form class="form" #formx="ngForm" (submit)="submit( formx.value)">
        <div class="form-body">
          <h4 class="form-section">
            <i class="icon-user"></i> Basic Details</h4>
          <div class="row">
            <div class="col-md-4">
              <div class="form-group">
                <label for="projectinput1">Event Name</label>
                <input type="text" id="projectinput1" class="form-control" name="eventname" ngModel>
              </div>
            </div>
            <div class="col-md-6">
                <div class="form-group">
                  <label for="projectinput3">Price</label>
                  <input type="text" id="projectinput3" class="form-control" name="price" ngModel>
                </div>
              </div>
          </div>
        </div>
        <div class="form-actions">
          <button type="button" class="btn btn-raised btn-danger mr-1">
            <i class="icon-trash"></i> Cancel
          </button>
          <button type="submit" class="btn btn-raised btn-success" >
            <i class="icon-note"></i> Save
          </button>
        </div>
      </form>

.ts

submit(data){
    if(this.img){
        data.photo = this.img;
    }
    console.log(data);
    data.timestamp = new Date();
    let final = {...data};
    console.log(final);
    this.api.addDeal(final).then(res=>{console.log(`deal created`);})
}

enter image description here

0 个答案:

没有答案