javascript - radio box selected item on angularjs -
i'm wonder how set selected item checked when i'm using radio button list
my sample code this
<div ng-repeat="vehicle in filteredvehicle"> <input type="radio" name="radiog_lite" id="radio_{{$index}}" class="css-checkbox" ng-value="vehicle" ng-model="$parent.selectedvehicle" ng-disabled="vehicle.enable == '0'" /> <label for="radio_{{$index}}" class="css-label radgroup1" ng-if="vehicle.enable == '1'"></label> <h5>{{vehicle.vehicletypename}}</h5>
below have created plunker please me fix selected item selected vehicle on $scope.selectedvehicle
thanks
you should bind selectedvehicle
object in array. reason behind angular add $$hashkey
every object.
use
$scope.selectedvehicle = {}; $scope.filteredvehicle = {}; $http.get('data.json').then(function(d){ angular.foreach(d.data.vehicletype, function(value, key) { if(value.vehicletypeid == d.data.selected.vehicletypeid){ $scope.selectedvehicle = value; } }); $scope.filteredvehicle = d.data.vehicletype; });
Comments
Post a Comment