如何在角度$ http服务请求中将JSONP指定为dataType?

dop*_*man 2 javascript ajax http angularjs

我熟悉使用jQuery $.ajax:

$.ajax({
  url: //twitter endpoint,
  method:"GET",
  dataType:"jsonp",
  success:function() {
    //stuff
  }
});
Run Code Online (Sandbox Code Playgroud)

如何JSONP为角度$http服务请求指定数据类型?

到目前为止我试过这个:

$http.get({
  url: //twitter endpoint,
  dataType: "jsonp",
  success: function(){
    //stuff
  }
});
Run Code Online (Sandbox Code Playgroud)

它没有工作.有任何想法吗?

tym*_*eJV 6

你可以随时使用 $http.jsonp(url).success(function() {} );

$ http.jsonp