jeudi 9 janvier 2020

pass id of the selected checkbox(which areloaded with ngFor) when it is checked

       <form name="check-boxes">
          <div *ngFor="let quest of noOfQuestions">
            <div class="form-check form-check-radio form-check-inline" *ngFor="let ans of noOfAnswers">
              <label class="form-check-label">
               <input class="form-check-input" type="radio" name="" id="" value=""  (change)="getAnswers(id)"> 
              <span class="form-check-sign"></span>
             </label>
            </div>
          </div>
      </form>

Sample Output in angular componentx.html: enter image description here

This code generates a set of combo boxes according to noOfQuestions and noOfAnswers provided. I want to pass the particular id of the checkbox to the function 'getAnswer' when a checkbox is checked. Passed parameter 'id' value in ts file, is said undefined. What should be the parameter to getAnswer() to pass the seleced check box's id???




Aucun commentaire:

Enregistrer un commentaire