Richard Watts
Richard Watts

Reputation: 1004

radio button will not bind properly Angular

I have the following view

<tr ng-repeat="item in items">
 <td>
<input type="radio" name="{{item.GroupName}}"  data-ng-value="   {{item.BooleanValue}}" />
     {{bookmark.BooleanValue}}
</td>

The above shows the text value of bookmark.BooleanValue after the radio button as true but the radio button is not selected.

I don need any complex binding to the viewmodel. The requirement is to make a DB call on selection (which I will get to once I can get the binding sorted

Any help?

Upvotes: 2

Views: 808

Answers (1)

Alex Logan
Alex Logan

Reputation: 1241

You use ng-value in conjunction with ng-model. ng-model specifies the property the radio button is bound to and ng-value is the value given to the bound property when that radio button is selected. See the docs.

<tr ng-repeat="item in items">
 <td>
<input type="radio" name="{{item.GroupName}}"  ng-model="item.BooleanValue" ng-value="true"/>
     {{item.BooleanValue}}
</td>

Upvotes: 1

Related Questions