6

If you update text input model "sg.Value", checkbox shoud be checked, but model "sg.AnswerId" is not set.

Sample

How to get:

Change text input -> Set checkbox model ?

<label>
  <input type="checkbox"
         ng-model="sg.AnswerId"
         ng-true-value="'{{answer.Id}}'"
         ng-checked="sg.Value != undefined"
         >
  <input type="text"
         placeholder="Your text"
         ng-model="sg.Value"
         >
</label>

Checkbox must become checked and it's model updated, when i typing in input.

1 Answer 1

1

My solution is plunkr

Listener on input change:

function trackInput(){
  if(sg.Value !== '' && sg.Value !== undefined) {
    sg.AnswerId = sg.answer.Id;
  } else {
    sg.AnswerId = false;
  }
};

Maybe anyone have better solution? Share please.

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.