How to set variable in Angular Scope JS

Asked

Viewed 381 times

1

I have the following dropdown:

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

I need to take the selected value in the dropdown (x.Street) and set in an attribute of another Cope called: home

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 property $scope.casa.rua (assuming that $scope.casa is a pre-existing object):

<select ng-model='casa.rua'> 
    <option ng-repeat="x in Ruas">{{x.Rua}}</option>
</select>
  • worked ! thanks Onosendai !

  • Always happy to help!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.