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

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -