我知道这里提出的这类问题,但在这些问题的帮助下将无法解决
组件
import { NgForm } from '@angular/forms';
onSubmit(f: NgForm) {
this.serverData.storeData('Analysis/Student Course Review', f.value)
.subscribe(
(response) => console.log(response,f.value),
(error) => console.log(error),
)
}
在app-module中我导入FormsModule
表单@angular/forms
并添加
imports: [
FormsModule
],
HTML
<form (ngSubmit)="onSubmit(f)" #f="ngForm">
<h2> {{basicInfoData[0]}}</h2>
<div class="form-control">
<div>
<label>
<strong>Batch:</strong>
<span> {{basicInfoData[1]}} </span>
</label>
</div>
<div>
<label>
<strong>Semester:</strong>
<span> {{basicInfoData[2]}} </span>
</label>
</div>
<div>
<label>
<strong>Subject:</strong>
<span> {{basicInfoData[3]}} </span>
</label>
</div>
</div>
<div *ngFor="let data of currentQuestionsValue">
<div *ngFor="let d of data.items " class="form-control">
<p>
<strong> {{ d.sno }}). </strong> {{ d.question}}</p>
<div>
<form>
<label *ngFor="let key of objectKeys(d.options)">
<input type="radio" name="option" [value]="d.options[key]">
<span>{{ d.options[key] }}</span>
</label>
</form>
</div>
</div>
</div>
<button type="submit" class="btn btn-primary"> Submit</button>
</form>
我想发布所有形式的值,但是它没有发布值,我找不到什么是错误
这是服务
storeData(url, servers: string) {
return this.http.post('https://onlinefeedbacksystem-d5978.firebaseio.com/' + url + '.json', servers);
}
答案 0 :(得分:1)
html元素上的ngModel在哪里?尝试使用ngModel和name属性,让我知道它是否有效。
<input type="radio" name="option" [value]="d.options[key]" ngModel>