Incorrect radio button getting selected for ng-repeat radio buttons

[亡魂溺海] 提交于 2019-12-11 12:39:31

问题


I have a list of radio buttons using ng-repeat. When I initially load the page and select on the last radio button, the button on it's side gets selected. This only happens for the first time, i.e. if I click on the last button a second time, it is selected correctly.

<input type="radio" name="rb" value="{{rbCollection.name}}" data-ng-click="open(name)" data-ng-model="Ctrl.selection">

回答1:


Check this so.

The problem is that ng-click fires before the ng-model code that updates the scope. If you change it to use ng-change, that will fix it. You also need to add ng-change to your text box to update the scope as the user types.



来源:https://stackoverflow.com/questions/35612352/incorrect-radio-button-getting-selected-for-ng-repeat-radio-buttons

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!