简体   繁体   English

如何在角度JS中执行基于查询字符串的API调用

[英]How to perform query string based API call in angular JS

I am very new to angualr js. 我是angualr js的新手。 I have found a very useful article about how to connect to API and use their information to show into our app using angular JS. 我找到了一篇非常有用的文章,内容涉及如何连接到API以及如何使用它们的信息通过angular JS展示到我们的应用程序中。

http://austinknight.net/weather-app-with-angular-js/ http://austinknight.net/weather-app-with-angular-js/

Only limitation is this weather forecast for US only. 唯一的限制是该天气预报仅适用于美国。 I can find many API which provided world wide forecast but I can't connect with them the way author has done here. 我可以找到许多提供世界范围预报的API,但是我无法像作者在这里所做的那样与他们联系。

$http.get('https://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20weather.forecast%20WHERE%20location%3D%22' + zip + '%22&format=json&diagnostics=true&callback=')

Can someone please help me to write up such a query string based API call for any country ? 有人可以帮我为任何国家编写基于查询字符串的API调用吗?

I have done sufficient research but couldn't find anything similar. 我已经做了足够的研究,但是找不到类似的东西。

Please help. 请帮忙。

You can pass params like this 你可以通过这样的参数

$http.get('https://query.yahooapis.com/v1/public/yql', {
      params: {
      q: 'your query',
      format: 'json',
      diagnostics: true,
      callback: ''
     }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM