0

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!

1 Answer 1

3

Just remove ng-checked attribute. Should help.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.