How to set a variable in the Scope Angular JS

1

I have the following dropdown:

<select> 
    <option ng-repeat="x in Ruas">{{x.Rua}}</option>
</select>

I need to get the value selected in the dropdown (x.Rua) and set it to an attribute of another scope called: home

    
asked by anonymous 30.09.2016 / 17:09

1 answer

3

Assign the selected value to a scope variable indicating a model property, via ng-model .

The following example stores the selection in the $scope.casa.rua property (assuming $scope.casa is a pre-existing object):

<select ng-model='casa.rua'> 
    <option ng-repeat="x in Ruas">{{x.Rua}}</option>
</select>
    
30.09.2016 / 19:19