Angularjs - How to pass selected switch value to controller

I have a list of dynamically created radio windows.

<div id="Address" class="modal-body" ng-show="AData">
    <h5>
        Select the correct address information from the list below.
    </h5>
    <label class="list-group-item" ng-repeat="address in Addresses">
        <input type="radio" class="SuggestAddresses" ng-model="SelectedAddress" name="grAVR" ng-value="address" />
        {{values.AddressLine1}} {{values.City}} {{values.State}} {{values.Zip}}
    </label>
</div>

I am trying to access the SelectedAddress model in my controller, but its value is undefined in the controller. When I save this value of the radio object model in a predefined scope variable that is already in my controller, it works fine.

+3
source share
1 answer

To add some clarification to the comment above, ng-model="adress.selectedAdress"let you access the obects property.

Please note that you are working with an object in the list provided adressin your ng-repeat. It correspondsAdresses[adress].selectedAdress

+2
source

All Articles