reflija
reflija

Reputation: 55

AngularJS JSON response

Screenshot

I tried accessing both response.data and response.data.data, but neither worked.

I need to get a country list for each different option from a JSON file.

webServices.getCountries({
}, function success(response) {
     $scope.countries = angular.fromJson(response);
});

My HTML:

<select class="dropdown" id="input4" name="countries"  >
    <option class="label">* Choose your location</option>
    <option ng-repeat="country in countries" value="{{country}}">{{country}}</option>
</select>

Upvotes: 0

Views: 48

Answers (1)

BeetleJuice
BeetleJuice

Reputation: 40936

Try replacing

$scope.countries = angular.fromJson(response);

With

$scope.countries = angular.fromJson(response).response.data;

Upvotes: 1

Related Questions