vendredi 22 mai 2015

Angular checkbox issue

I have kind of a huge issue.

I have the following checkbox:

<input type="checkbox" ng-model="answer.is_correct"  ng-checked="answer.is_correct == 1" ng-true-value="1" ng-false-value="0">

Now when i check this save it and reload the page the answer object looks like this:

answer: "B" id: 493 is_correct: 1 question_id: 214 question_question_type_id: 1__proto__: Object2: Objectanswer: "C"id: 494 is_correct: 1 question_id: 21 4question_question_type_id: 1

Which result in the checkbox being checked:

enter image description here

And now the bug starts. if i uncheck the checkbox the value is not changed. because it is initilized to one. So in order to change the value i have to do the following:

  • Uncheck the checkbox
  • Check the checkbox
  • Uncheck the checkbox

This is ofcourse not good so i am praying someone has tried it before or know how i might fix it!




Aucun commentaire:

Enregistrer un commentaire