javascript - Angular UI.Bootstrap's radio buttons act strange with ng-repeat -
this question has answer here:
i have problem dynamically generating options radio model in angular's ui.bootstrap. thought ng-repeat on array, using it's contents btn-radio attribute so:
//in controller $scope.radiomodel = undefined; $scope.radiomodelbuttons = ["a", "b", "c"]; //in html <div class="btn-group" > <button ng-repeat="value in radiomodelbuttons" class="btn" type="button" ng-model="radiomodel" btn-radio="'{{value}}'"> {{value}} </button> </div>
i'm using angular 1.1.4 , ui.bootstrap 0.3.0.
here jsfiddle of efforts, can see, radio buttons act independently , not affect radiomodel variable.
thanks!
this how should write markup:
<button ng-repeat="value in radiomodelbuttons" class="btn" type="button" ng-model="radio.model" btn-radio="value"> {{value}} </button>
and working jsfiddle: http://jsfiddle.net/ymlqz/2/
there 2 problems in approach:
btn-radio
should used angularjs expression, , not interpolated valueng-repeat
creating new scope need take account if want bind value defined on parent scope
Comments
Post a Comment