0

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>
4
  • console.log($scope.countries) output?? also create a plunker for demo. Commented Jun 28, 2016 at 8:25
  • i cant create plunker it's really complicated code. i.prntscr.com/47b20958d7a643bca1b06c852406dd7d.png Commented Jun 28, 2016 at 8:29
  • Your given link is blocked on my premise. :( use imgur Commented Jun 28, 2016 at 8:33
  • try this: $scope.countries = response.data; Commented Jun 28, 2016 at 10:38

1 Answer 1

1

Try replacing

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

With

$scope.countries = angular.fromJson(response).response.data;
Sign up to request clarification or add additional context in comments.

5 Comments

Didnt work no results showing. Even the output now is undefined.
Thanks the last one worked. $scope.countries = angular.fromJson(response).response.data;
Ok. I've updated my answer to remove the option that didn't work for you. Please select it if it helped you.
Where can i do that?
Next to the top left of my answer you'll see a number (currently -1) between an up and a down arrow. click the up arrow if you like the answer, the down arrow if you don't. Under the down arrow, you'll see a check mark. Click the check mark if you wish to select it as the answer that helped you. By the way you should probably select the answer that helped you on your previous question as well. You left a comment saying the user "saved your day" but did not select his or her answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.