Angular UI.Bootstrap'的单选按钮在ng-repeat中表现得很奇怪
Angular UI.Bootstrap's radio buttons act strange with ng-repeat
我在angular的ui.bootstrap中动态生成无线电模型的选项时遇到了一个问题。我想我可以简单地重复数组,使用它的内容为btn-radio属性,像这样:
//in the controller
$scope.radioModel = undefined;
$scope.radioModelButtons = ["a", "b", "c"];
//in the html
<div class="btn-group" >
<button ng-repeat="value in radioModelButtons"
class="btn" type="button" ng-model="radioModel"
btn-radio="'{{value}}'">
{{value}}
</button>
</div>
我使用angular 1.1.4和ui。引导0.3.0。
这是我的工作示例,如您所见,单选按钮独立工作,不影响radiommodel变量。
谢谢!
你应该这样写你的标记:
<button ng-repeat="value in radioModelButtons"
class="btn" type="button" ng-model="radio.model"
btn-radio="value">
{{value}}
</button>
和工作jsFiddle: http://jsfiddle.net/yMLqz/2/
你的方法有两个问题:
-
btn-radio
应该与AngularJS表达式一起使用,而不是插入值 -
ng-repeat
正在创建一个新的作用域,所以如果你想绑定到父作用域 上定义的值,你需要考虑到这一点
相关文章:
- ng init中的表达式无法使用ng repeat
- Angular ng repeat order将多个字段作为一个字段
- 访问ng repeat中的第一个项目
- Angular js+ng repeat+字母数字索引不起作用
- 如何正确应用Angularjs ng repeat
- AngularJS Navigation (li ng-repeat, create header li), DOM
- 如何使用ng repeat中的选定输入更新我的对象
- 无法使用ng repeat检索动态创建的JSON对象的属性
- 使用 ng-repeat访问 ng 表单元素/值
- Toggle Switch在包含ng model和ng repeat之后不进行切换
- 如何在ng repeat angular js中使用$index
- 在Angularjs中,我如何使用ng repeat、ng model和ng click来动态更改内容
- 使用 ng-repeat 与 bootstrap 的进度条
- AngularJS UI-Bootstrap Datepicker在ng-repeat中不起作用
- 如何使用angularJS的ng-repeat在循环中显示bootstrap的折叠面板
- Angular UI.Bootstrap'的单选按钮在ng-repeat中表现得很奇怪
- 使用ng-repeat用实时数据更新bootstrap angularjs表
- AngularJS and Bootstrap: ng-repeat and paginator
- AngularJS和Bootstrap的ng-repeat表生成
- Angular ng-repeat with bootstrap输入复选框,动态ng-model使用ng-true-va