Question

I have this HTML set up

<input type="radio" value="yes" ng-model="sa" style="width:10px;"> Yes &nbsp;&nbsp;&nbsp;&nbsp;
<input type="radio" value="no"  ng-model="sa" style="width:10px;"> No
<br /><br />
<div ng-show="sa == 'yes'">
    <textarea form-title="Please outline your requirements" title-placement="top" ckeditor ng-model="form.equal.interviewArrangements"></textarea>
    <br /><br />
    <p class="alert alert-error warning" ng-show="errorAt[14]">
        Please enter your requirements or choose no above
    </p>
</div>
<input type="button" class="btn btn-primary nextStep" value="Send Application" ng-click="sendApplication()" />

Which all works fine, the div is shown when the radio yes is selected, now in sendApplication() I have this line

log($scope.sa);

That is always logged as undefined, no matter what radio box is selected. What have I got wrong?

If in my controller I add $scope.sa = 'no'; by default the radio is set to No which is corrent, but when I change it to yes, and then log the variable it always logs as no.

Was it helpful?

Solution

In short, you should respect the "dot rule":

<input type="radio" value="yes" ng-model="data.sa" style="width:10px;">
<!-- … -->
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top