0

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.

TMH
  • 6,096
  • 7
  • 51
  • 88

1 Answers1

1

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

<input type="radio" value="yes" ng-model="data.sa" style="width:10px;">
<!-- … -->
Community
  • 1
  • 1
Blackhole
  • 20,129
  • 7
  • 70
  • 68
  • That's funny, the form data is stored in (As you can see from the textarea) form.whatever, just before you posted this I moved the sa variable into the form data object and it works fine. I'll have a read through of that question you linked to now. Cheers! – TMH May 15 '14 at 23:10