1
<div ng-app="myApp" ng-controller="customersCtrl"> 
<ul>
<li ng-repeat="x in myData">
{{ x.Name + ', ' + x.Country }}
</ul>
 </div>

<script>
var app = angular.module('myApp', []);

app.controller('customersCtrl', function($scope, $http) {
  $http.get("customers.php").then(function (response) {
      $scope.myData = response.data;
  });
});

</script>

My json file is this

{"Name":"Peter","Country":"Germany"}, 
{"Name":"Ana","Country":"Mexico"}

I try to call it ,but not successful, any idea Thanks.......

1
  • can check your console? and post the error Commented Sep 22, 2017 at 4:15

1 Answer 1

1

Your JSON file's format is incorrect, it must have a top-level type. In your case, an array would be ok.

[
  {"Name":"Peter","Country":"Germany"}, 
  {"Name":"Ana","Country":"Mexico"}
]

Check this post Can an array be top-level JSON-text? for some more detail.

Sign up to request clarification or add additional context in comments.

Comments

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.