This is my client side :
<ion-card *ngFor="#p of posts | async">
<ion-card-header>
{{p.title}}
</ion-card-header>
<ion-card-content>
<form [ngFormModel] = 'form' (ngSubmit) = 'addcomment(form.value, p.$key)'>
<ion-input type="text" placeholder="your comment" (ngModel) = 'comment'></ion-input>
<button>add comment</button>
</form>
</ion-card-content>
</ion-card>
And in .ts :
this.form = fb.group({
'comment': ['', Validators.required]
});
this.comment = this.form.controls['comment']
If i print in the console the form.value
inside addcomment()
Control {asyncValidator: null, _pristine: true, _touched: false, _value: "", _errors: Object…}
and this.comment
(AbstractControl
type of variable inside class) is empty.