kevin_b
kevin_b

Reputation: 863

How to do radio buttons in Angular

This is my code. When I submit switchColors, the server returns undefined for it. How is this wrong?

Also how should I initiate $scope.swichColors in my controller? Currently I have $scope.switchColors = '';

<label class="radio-inline">
    <input type="radio" ng-model="$parent.switchColors" value = "yes" >Yes</input>
</label>

<label class="radio-inline">
    <input type= "radio" ng-model = "$parent.switchColors" value = "no" >No</input>
</label>

Upvotes: 0

Views: 69

Answers (1)

LazyDeveloper
LazyDeveloper

Reputation: 619

Try using ng-value instead of value

 <label class="radio-inline">
        <input type="radio" ng-model="$parent.switchColors" ng-value = "yes" >Yes</input>
    </label>

    <label class="radio-inline">
        <input type= "radio" ng-model = "$parent.switchColors" ng-value = "no" >No</input>
    </label>

Upvotes: 1

Related Questions