angularjs實(shí)現(xiàn)天氣預(yù)報(bào)功能的源代碼

這篇文章將為大家詳細(xì)講解有關(guān)angularjs實(shí)現(xiàn)天氣預(yù)報(bào)功能的源代碼,小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。

創(chuàng)新互聯(lián)是一家專(zhuān)業(yè)提供鎮(zhèn)雄企業(yè)網(wǎng)站建設(shè),專(zhuān)注與成都網(wǎng)站設(shè)計(jì)、網(wǎng)站建設(shè)、H5高端網(wǎng)站建設(shè)、小程序制作等業(yè)務(wù)。10年已為鎮(zhèn)雄眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專(zhuān)業(yè)網(wǎng)站制作公司優(yōu)惠進(jìn)行中。

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <title>天氣</title>
 <script src="../angular-1.5.5/angular.min.js"></script>
 <script>
  var u1="https://free-api.heweather.com/v5/weather&#63;city=";
  var u2;
  var u3="&key=545d63e185fc48169a43cbabba6e74d2";
  var my=angular.module("my",[]);
  my.controller("mys",function ($scope,$http) {
   $scope.city="beijing";
   $scope.show=false;
   $scope.search=function () {
     u2=$scope.city;
     $scope.show=true;
     $http({
      url:u1+u2+u3
     }).then(function (data) {
      $scope.cityName=data.data.HeWeather5[0].basic.city;
      $scope.date=data.data.HeWeather5[0].daily_forecast[0].date;
      $scope.mTemp=data.data.HeWeather5[0].daily_forecast[0].tmp.max;
      $scope.xTemp=data.data.HeWeather5[0].daily_forecast[0].tmp.min;
     })
    $scope.city="";
   };
  })
 </script>
</head>
<body ng-app="my" ng-controller="mys">
 <input type="text" ng-model="city"/><button ng-click="search()">點(diǎn)擊查詢(xún)</button>
 <ul ng-show="show">
  <li>{{cityName}}</li>
  <li>{{date}}</li>
  <li>{{mTemp}}</li>
  <li>{{xTemp}}</li>
 </ul>
</body>
</html>

關(guān)于angularjs實(shí)現(xiàn)天氣預(yù)報(bào)功能的源代碼就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到。

文章名稱(chēng):angularjs實(shí)現(xiàn)天氣預(yù)報(bào)功能的源代碼
分享鏈接:http://muchs.cn/article2/gdshic.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導(dǎo)航、網(wǎng)站收錄網(wǎng)站排名、Google響應(yīng)式網(wǎng)站、靜態(tài)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站建設(shè)