toshieeeee
3/17/2017 - 11:56 AM

getWeather_temp.js

/*******************************
コントローラー
********************************/


weatherApp.controller('forecastController',['$scope','$resource','$http','$routeParams','cityService',function($scope,$resource,$http,$routeParams,cityService){


  $scope.city = cityService.city; 

  $scope.days = $routeParams.days||'2';
  
  $scope.weatherAPI = $resource('http://api.openweathermap.org/data/2.5/forecast/daily',{

    jsonpCallbackParam: 'callback'}, {

    get: {

      method:  'JSONP'

    }

  });

  // q=Osaka&unit=mertic&cnt=6&appid=68707c40fd134da0ab487c7196e24325

  $scope.weatherResult = $scope.weatherAPI.get({

    q: $scope.city,
   // unit: mertic,
    //cnt :$scope.days,
    // description : $scope.description,
    appid: '68707c40fd134da0ab487c7196e24325'

  });

  // console.log($scope.weatherResult['list']);


  $scope.convertToCelius = function(degK){
    return Math.round(degK - 273.15);
  };

  $scope.convertToDate = function(dt){
    return new Date(dt * 1000);
  };

}]);