Adeel
Adeel

Reputation: 143

Form is not submitted to firebase

I know that this type of question asked here but with the help of these my problem won't be solved

Component

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),
      )
  } 

in app-module I import FormsModule Form @angular/forms and also add in

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>

I want to post all the values which are in form but it to not posted values and I do not find what is error

this is service

storeData(url, servers: string) {
    return this.http.post('https://onlinefeedbacksystem-d5978.firebaseio.com/' + url + '.json', servers);
  }

this is output in console.log enter image description here

Upvotes: 1

Views: 154

Answers (1)

Robert Williams
Robert Williams

Reputation: 1410

Where is ngModel on html element? Try ngModel along with name property and let me know if it worked.

<input type="radio" name="option" [value]="d.options[key]" ngModel>

Upvotes: 1

Related Questions