williamsandonz
williamsandonz

Reputation: 16440

Why isn't my angular radio button marked as selected ( i have to click twice)

<li ng-repeat="flagVm in flagVms track by $id(flagVm)">
    <label for="alternative{{$index}}" ng-click="alternativeClicked()">
        <input ng-model="$parent.alternative" value="{{ flagVm.id }}" type="radio" name="alternative{{$index}}" /> 
        <span class="num-times-flagged">(Flagged {{ flagVm.count }} {{ flagVm.count > 1 ? 'times' : 'time' }}) </span>
        Inference Id: 
        <span class="highlighted-id">{{ flagVm.duplicateId }}</span>
    </label>
</li>

and

$scope.alternativeClicked = function (id) 
{
    //once iterating will probably be the actual flag obj
    $scope.alternativeFound = 'yes';
};

Upvotes: 0

Views: 482

Answers (1)

Chen-Tsu Lin
Chen-Tsu Lin

Reputation: 23244

I think using ng-click with radio is a bad practice.

The better way is to use ng-change or $watch value change

Upvotes: 1

Related Questions