0

Helo everyone, I have a problem with angular js , I'm developing a small app for weather, and I am using open weather map , but i have error when i launch my app

here's the result of the app when launching enter image description here

here's my code

// SERVIRES
weatherApp.service('cityService', function() {

    this.city = "New York, NY";

});

// CONTROLLERS

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

    $scope.city = cityService.city;

    $scope.weatherAPI = $resource("https://api.openweathermap.org/data/2.5/forecast?q=London,us&mode=xml&appid=c4b636e853d2b065e2da4c55eb26e662", { callback: "JSON_CALLBACK" }, { get: { method: "JSONP" }});

    $scope.weatherResult = $scope.weatherAPI.get({ q : $scope.city });

    $scope.convertToFahrenheit = function(degK) {

        return Math.round((1.8 * (degK - 273)) + 32);

    };

    $scope.convertToDate = function(dt) {

      return new Date(dt * 1000);  

    };

}]);
5
  • You should have specified which error if it is in console or somewhere else. Commented Apr 11, 2020 at 23:10
  • the result of temperature is NaN not showing me the result .. Commented Apr 12, 2020 at 0:10
  • inside $scope.convertToFahrenheit function add this instead : return Math.round(degK * 1.8 + 32) Commented Apr 12, 2020 at 16:24
  • No, didn't work :( Commented Apr 13, 2020 at 14:22
  • Please create a working demo. I will edit it for you. Commented Apr 14, 2020 at 4:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.