javascript - Angular UI.Bootstrap's radio buttons act strange with ng-repeat -


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 value
  • ng-repeat creating new scope need take account if want bind value defined on parent scope

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -