给大家做一个关于天气的例子
2017-09-20 14:15
295 查看
myapp.controller("chaxunController",function ($scope,$http) { var ul1="https://free-api.heweather.com/v5/weather?city="; var ul2; var ul3="&key=545d63e185fc48169a43cbabba6e74d2"; $scope.city="阳泉"; $scope.show=false; $scope.chaxun=function () { ul2=$scope.city; $scope.show=true; $http({ url:ul1+ul2+ul3 }).then(function (data) { console.log(data); $scope.city2=data.data.HeWeather5[0].basic.city; $scope.date=data.data.HeWeather5[0].suggestion.air.txt; $scope.dir=data.data.HeWeather5[0].now.wind.dir; $scope.city=""; }); /* $scope.show=false;*/ } });
<div class="haha4"> <input type="text" ng-model="city"/><button ng-click="chaxun()">查询</button> <ul ng-show="show"> <li>{{city2}}</li> <li>{{date}}</li> <li>{{dir}}</li> </ul>
相关文章推荐
- 给大家做了一个关于日程的例子,可以参考一下,对进一步学习有所帮助
- 遇到的一个关于NULL小问题,请大家帮忙看下,求个解释
- 一个非常有用的关于集合的例子,实现集合的add,remove和this[index]方法
- 好久没上博客园了,给大家送上一个自绘进度条的小例子
- 关于模板编程的一个例子 来自深度探索c++对象模型
- 关于《Windows驱动开发技术详解》第16章 16.6例子中一个问题
- 关于Java中的继承和组合的一个错误使用的例子
- 【读书笔记】MSDN 上关于加密解密的一个例子
- 【转】 关于ExpandableListView用法的一个简单小例子
- 一个天气接口的封装及使用例子
- 关于Java的RMI编程的一个简单的例子
- 关于封装--一个有趣的C++例子
- 一个关于jqGrid使用的小例子(行按钮)
- 关于领导与员工相处的一个例子
- 带领大家一起做一个ThinkPHP整合jcrop图片上传裁切预览的例子 推荐
- 关于attr的用法,自己写的一个例子。
- 关于多线程的一个例子(UI实时显示)
- 自制简单的Java下载器——来自《Java高级编程》的一个关于线程的例子(带上部分注释)
- 关于ExpandableListView用法的一个简单小例子
- 一个不错的关于sql数组的使用例子