【发布时间】:2016-08-03 01:20:23
【问题描述】:
这是我的客户端:
<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>
在 .ts 中:
this.form = fb.group({
'comment': ['', Validators.required]
});
this.comment = this.form.controls['comment']
如果我在控制台中打印form.value 内的addcomment()
Control {asyncValidator: null, _pristine: true, _touched: false, _value: "", _errors: Object…}
而this.comment(类内变量的AbstractControl类型)为空。
【问题讨论】:
标签: angularjs angular ionic2 ionic-view angular2-forms