Joe82 Joe82 - 5 months ago 40
AngularJS Question

AngularJS - Change scope with one of the iterations of a ng-repeat

I have a project with Angular where I don't want to use a select element with ng-options, so I made up a list with different options in order to select one of them.

<div class="countrylist">
<li ng-repeat="c in shippingCountry"><p>{{}}</p></li>

So the option selected would modify another element where the chosen option would be displayed.


In order to do that, I would need to pass the data from the chosen option of the first element into the 2nd one. I have tried doing something like this

<li ng-repeat="c in shippingCountry" ng-click="selectedCountry = {{c}}"><p>{{}}</p></li>

with no success.

You can check the plunker here Thanks in advance


I suggest you to use a function over there like this in the DEMO

<li ng-repeat="c in shippingCountry" ng-click="Click(c)"><p>{{}}</p></li>

Having this method in your controller

$scope.Click=function (c)