How to get the selected items if you choose more than one link, for example, I choose the USA and Can, Fra, Ger, China ... So how can I get the selected items from the ng-model
?
The view
is below:
<div class="layer-box picker-box toggle-box get-value" id="picker-filter-country">
<div class="list-header"><a href="#" class="layer-close icon-close">X</a><span class="t">country</span></div>
<input type="search" autocomplete="off" class="box-search" name="searchcountry" ng-model="searchcountry">
<a href="#" data-val="{{country.key}}" class="item" ng-repeat="country in territories | filter:searchcountry " ng-model="country.name">{{country.name}}</a>
<a class="layerbutton t" ng-click="search()">done</a>
</div>
How can I get the results like $scope.(name of ng-model)
in the controller? It doesn't work if I obtain them by $scope.country.name
.
PS: It will create a list of countries in the form of links, if you click one, it will be choosen...
please have a look to : PLUNKER
<select multiple ng-model="selectedValues">
<option value="1">Blue</option>
<option value="2">Green</option>
<option value="3">Yellow</option>
<option value="4">Red</option>
</select>
and js code
$scope.selectedValues = [];
Okay, I think I understand your question.
In your views
, try passing the parameter of the ng-model
of your selected country into your search function, refer to the example below.
<a class="layerbutton t" ng-click="search(country.name)">done</a>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.