I have a webapp dedicated to TV Shows. A controller fetches the registered TV Shows:
$http.get('/shows').success(function(data) {
$scope.shows = data;
var temp = data[0];
$scope.radio-input-shows = temp['name'];
});
This is passed to an AngularJS view, which displays them with a radio button.
<div class="col-use-list sidebar">
<div class="col-md-12 sidebar-element sidebar-triangle" ng-repeat="show in shows" style="margin-bottom: 10px;">
<div class="col-use-icon" style="padding-left: 0px;">
<img alt="{{ show.name }}" src="img/artwork/{{ show.image_name }}.png" style="width:60px;height:60px;">
</div>
<div class="col-use-name">
<p>{{ show.name }}</p>
</div>
<div class="col-use-select">
<input type="radio" name="sidebar-radio" ng-model="radio-input-shows" value="{{ show.image_name }}">
</div>
</div>
<tt>Show = {{radio-input-shows | json}}</tt><br/>
</div>
What I need now is to pass the name of a show as a value to the radio input. Is this even possible?
=================
So I now changed the input to this <input type="radio" name="checkbox" ng-model="tvshow" ng-value="show.name">. And changed this <tt>Show = {{tvshow}}</tt><br/>. However, it's still not updating if I click on another radio button...
`
ng-model. Sinceng-repeatcreates child scopes you will have inheritance problems. Always have a dot inng-modelwhich means passing object properties not primitives