Reputation: 3961
I'm pretty new to AngularJS, and have a (maybe simple or stupid) question.
I have a input radio box, with a ng-model, the value depends on a condition
<input type="radio" name="q_{{question.id}}" ng-model="question.option.id" value="{{!survey.isOptionSelected(question.related_question_option_id) ? 0 : opt.id}}">
my problem is that ng-model="question.option.id" is not changing when (or if) the condition changes .. is there a way update it with the current value?
Upvotes: 1
Views: 2918
Reputation: 11398
Maybe I'm wrong, but looking at your code, it looks like you're trying to enable/disable some radio buttons depending on a checkbox.
<input type="radio" name="q_{{question.id}}"
ng-model="question.option.id"
value="{{opt.id}}"
ng-disabled="survey.isOptionSelected(question.related_question_option_id)" />
Ain't this a better option?
And, if your condition changes, you must add a $watch
on the select that can change, and update the question.option.id
inside the callback
Upvotes: 2
Reputation: 794
You need to replace value
with ng-value
: https://docs.angularjs.org/api/ng/directive/ngValue
Upvotes: 0