If you update text input model "sg.Value", checkbox shoud be checked, but model "sg.AnswerId" is not set.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With