
"use strict";

angular.module('myapp')
  .controller("WeatherController", function($scope, $http){
    $scope.location = {};
    $scope.weather = {};
    $scope.cityForecast = "";
    //if (navigator.geolocation) navigator.geolocation.getCurrentPosition(onPositionUpdate);
     
      function startForecast(){
    //function onPositionUpdate(position) {
      //var lati = position.coords.latitude;
      //var longi = position.coords.longitude;
      /*var url = 'https://api.wunderground.com/api/4a82154c39d11213/conditions/geolocation/q/' + lati + ',' + longi + '.json';*/
     // var url = 'https://api.wunderground.com/api/4a82154c39d11213/geolookup/q/' + lati + ',' + longi + '.json';
      var url = "https://api.wunderground.com/api/4a82154c39d11213/forecast/q/autoip.json";
      $http.get(url)
        .then(function(info) {
          console.log(info);
          $scope.location.city = info.data.location.city;
          $scope.location.state = info.data.location.nearby_weather_stations.state;
          $scope.location.country = info.data.country;
          $scope.retrieveCity($scope.location.country, $scope.location.state, $scope.location.city)
      
        });
        startForecast();
    //}
    /*$scope.retrieveCity = function(country, state, city){
     city = city.replace(" ", "_");
      
     if(country === "US"){
       $scope.cityForecast = 'https://api.wunderground.com/api/4a82154c39d11213/forecast/q/' + state + "/" + city + ".json";
     }else{
        $scope.cityForecast = 'https://api.wunderground.com/api/4a82154c39d11213/forecast/q/' + country + "/" + city + ".json";
     }
     $http.get($scope.cityForecast)
      .then(function(data){
       console.log(data);
     });*/
     
      
   };
  
  });
  

@@ -178,18 +178,16 @@
 %22%22;%0A    
-//
 if (navi
@@ -280,41 +280,13 @@
     
- function startForecast()%7B
 %0A    
-//
 func
@@ -321,26 +321,24 @@
 on) %7B%0A      
-//
 var lati = p
@@ -368,18 +368,16 @@
 ;%0A      
-//
 var long
@@ -413,18 +413,16 @@
 ;%0A      
-/*
 var url 
@@ -536,217 +536,21 @@
 on';
-*/
 %0A     
-// var url = 'https://api.wunderground.com/api/4a82154c39d11213/geolookup/q/' + lati + ',' + longi + '.json';%0A      var url = %22https://api.wunderground.com/api/4a82154c39d11213/forecast/q/autoip.json%22;
+%0A      
 %0A   
@@ -629,32 +629,34 @@
 nfo);%0A          
+//
 $scope.location.
@@ -689,32 +689,34 @@
 city;%0A          
+//
 $scope.location.
@@ -779,24 +779,26 @@
 ;%0A          
+//
 $scope.locat
@@ -836,24 +836,26 @@
 ;%0A          
+//
 $scope.retri
@@ -961,26 +961,8 @@
     
-  
-startForecast();
 %0A   

Update controller1.js