Currently, I am storing an array in a Firestore document and I am trying to add another object to it but facing some issues. For instance, value:m1 , status:open
The code snippet below is from home.html
, where you can find [(ngModel)]="words2[in].value"
When attempting
[(ngModel)]="words2[in].value",open.status
, it throws an error
<form #formRef="ngForm">
<div *ngFor="let word2 of words2; let in=index" class="col-sm-3">
<div class="form-group">
<div class="milestones">
<ion-input type="text" placeholder="Milestone"
[(ngModel)]="words2[in].value" name="name{{in}}" class="form-control"
#name="ngModel" required (ionChange)="chng(words2[in].value)"></ion-input>
</div>
</div>
<br />
</div>
<button [disabled]="!formRef.form.valid" (click)="add()">Add Milestone +</button>
</form>
<br />
<br />
<ion-button (click)="CreateNewProject()">
<ion-icon size="small" slot="icon-only" name="add"></ion-icon>
Create new Project
</ion-button>
In home.ts
, when creating a record, the approach is to pass this.word2
as shown in the following code:
CreateNewProject(){
console.log(this.words2);
let record = {};
record['name'] = this.val1;
record['desc'] = this.val2;
record['milestone'] = this.words2;
...
This is how data is stored in Firestore: