angularjs - Get JSON response to Angular from Flask backend -


i want json response flask backend angular app not find error is. returning json response is:

{   "phones": [     {     "age": 0,      "name": "nexus s",      "snippet": "fast got faster nexus s."     },      {     "age": 1,      "name": "motorola xoom wi-fi",      "snippet": "the next, next generation tablet."     },      {     "age": 2,      "name": "motorola xoom",      "snippet": "the next, next generation tablet."     }   ] } 

and here controller:

function phones($scope, $http){ $http.get('127.0.0.1:5000/phones').success(function(data){ $scope.phns = data.phones;     console.log("i'm called"); }); } 

this works when pass json object controller this:

$scope.phones = [ {"name": "nexus s",  "snippet": "fast got faster nexus s.",  "age": 0}, {"name": "motorola xoom wi-fi",  "snippet": "the next, next generation tablet.",  "age": 1}, {"name": "motorola xoom",  "snippet": "the next, next generation tablet.",  "age": 2} ]; 

it doesn't work when try data data.phones. i'm sure controller gets called function not data somehow.

adding "http" 127.0.0.1:5000/phones should solve problem.


Comments