I've got a set of radio buttons in a ng-repeat, following what I found in this answer. I just can't figure out how to add an ng-model to it.
<tr ng-repeat="service in selectservice.services track by $index">
<td>
<input type="radio" name="serviceSelections" ng-value="{{service.name}}" id="service{{service.name}}">
</td>
<td>
<h3>
{{service.name}}
</h3>
<p>{{service.caption}}</p>
</td>
</tr>
With this controller:
(function() {
'use strict';
angular.module('pb.ds.selectservice').controller('SelectServiceController', function($log) {
var _this = this;
_this.selectedService = 0;
_this.services = [
{
selected: false,
name: 'Postmates',
caption: 'Guaranteed delivery within time'
},
{
selected: true,
name: 'Deliv',
caption: 'Guaranteed delivery within time',
},
{
selected: false,
name: 'Roadie',
caption: 'Guaranteed delivery within time',
}
];
});
})();
and, in my route, for this view:
content: {
controller: 'SelectServiceController as selectservice',
templateUrl: 'modules/select-service/templates/select-service.html'
},
The radio group correctly shows the second radio selected. But how do I update the model? What, exactly is the model? I have tried ng-model="selectservice.selectedService" which should be 0, but then no radio is selected.
ng-modelfor eachradio buttonservice.name,service.selected, nothing works.ng-model. I do not see that in yourhtml<input type="radio" ng-model="service.selected" name="serviceSelections" id="service{{service.name}}">