javascript - Cant fetch json and viewing it in angular unless i edit the json -
i want access json exact same format:
{"employees":[ {"firstname":"john", "lastname":"doe"}, {"firstname":"anna", "lastname":"smith"}, {"firstname":"peter", "lastname":"jones"} ]}
script:
phonecatapp.controller('phonelistctrl', ['$scope', '$http', function($scope, $http) { $http.get('employees/employees.json').success(function(data) { $scope.resources = data; });
if remove "employees" attributes inside [] iwill data. if left example above cant reach data.
any appreciated.
you need follow structure of json. since data entire json string array of employees accessible via employees key. try this:
$scope.resources = data.employees;
Comments
Post a Comment