francoleung francoleung - 6 months ago 34
JSON Question

How to use AngularJS to call json file

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

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

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


My json file is this


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

Answer Source

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


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

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