【发布时间】:2015-01-08 17:15:58
【问题描述】:
我开始学习 Angular,我想尝试一下 $http 调用函数。 我基本上想向外部 API 发出 get 请求:
angular.module('pokedexApp')
.controller('MainCtrl', function ($scope, $http) {
var response;
$http.jsonp("http://pokeapi.co/api/v1/pokemon/1/").success(function(response) {
response = response;
})
$scope.pokemon = response;
});
我可能完全错了它是如何工作的。我基本上是想{{ pokemon }}出一个回复来测试一下。
我收到Uncaught SyntaxError: Unexpected token : 错误,我不知道是因为返回数据的格式不正确还是什么原因。
【问题讨论】: