javascript - Change radio model on button click [angularjs] -


What do I want to achieve, when I click on the button change input, the model of the radio changed "value" goes . Why do I need to double click, so that the model can be updated and the radio is checked?

  & lt; Div ng-app ng-controller = "Ctrl" & gt; & Lt; Input type = "radio" ng-model = "value" ng-value = "33" & gt; & Lt; Input type = "radio" ng-model = "value" ng-value = "22" & gt; {{Value}} & lt; Button onclick = "changeInput ()" & gt; Input input & lt; / Button & gt; & Lt; / Div & gt;   

JS

  function Ctrl ($ scope) {} function changeInput () {$ ('input: eq (0)'). Click () .click (); } 

The probability is because the value is updated before your onclick function. Why do not you update the value in your onclick function and use only one click?

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -