所以...我正在尝试使用 ng-repeat 生成一个单选按钮组:
<div class="btn-group yb-radiobuttons">
<button type="button" class="btn" ng-model="radioModel" btn-radio="'all'">All locations ({{dreamboxItemsByDate.length}})</button>
<button type="button" class="btn" data-ng-repeat="(key, value) in items" ng-model="radioModel" btn-radio="'{{key}}'">{{key}} ({{value.length}})</button>
</div>
这会生成以下 html:
<div class="btn-group yb-radiobuttons">
<button class="btn ng-pristine ng-valid ng-binding" btn-radio="'all'" ng-model="radioModel" type="button">All locations (10)</button>
<button class="btn ng-scope ng-valid ng-binding ng-dirty active" btn-radio="'Brooklyn, New York'" ng-model="radioModel" data-ng-repeat="(key, value) in items" type="button"> Brooklyn, New York (6) </button>
<button class="btn ng-scope ng-valid ng-binding ng-dirty active" btn-radio="'London, UK'" ng-model="radioModel" data-ng-repeat="(key, value) in items" type="button"> London, UK (2) </button>
<button class="btn ng-scope ng-pristine ng-valid ng-binding" btn-radio="'Tokyo, Japan'" ng-model="radioModel" data-ng-repeat="(key, value) in items" type="button"> Tokyo, Japan (2) </button>
</div>
第一眼看起来一切都很好,但是单击使用重复生成的任何按钮元素根本不会设置模型 - 只需单击所有位置的按钮即可设置模型。
plnkr:http ://plnkr.co/edit/J1LfRO?p=preview
任何想法为什么会发生这种情况/如何解决?