CrazzyMarc CrazzyMarc - 1 year ago 77
AngularJS Question

AngularJS, how to use JSON from child in parent?

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:


<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">{{}}</option>


method: 'GET',
url: 'assets/json/currency.json'
}).then(function successCallback(response) {
$scope.items =;
}, function errorCallback(response) {
console.log("Oh shit, JSON is not working");

Answer Source

Use the ng-model directive in combination with the ng-options:

<select ng-options="item as for item in items" 

Then in your div:

{{ }}

See this jsfiddle

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download