When an item is selected in the select box, I want to use the other field in the parent div. In this case the country.
My code:
index.php
<div class="field" id="{{$index+1}}" ng-repeat="t in getTimes(fieldSelect) track by $index")>
<select name="drop_down" class="marketSelect">
<option ng-repeat="item in items">{{item.name}}</option>
</select>
{{item.country}}
</div>
angular.js
$http({
method: 'GET',
url: 'assets/json/currency.json'
}).then(function successCallback(response) {
$scope.items = response.data.currency;
}, function errorCallback(response) {
console.log("Oh shit, JSON is not working");
});
Use the ng-model
directive in combination with the ng-options
:
<select ng-options="item as item.name for item in items"
ng-model="selectedItem">
</select>
Then in your div:
{{ selectedItem.country }}
See this jsfiddle
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.