2017-02-21 5 views
0

일기 예보에 대한 간단한 응용 프로그램이 있습니다. 위치 아래의 결과 목록지시문의 캐시 새로 고침

  • 클릭에 대한

    1. 검색 :이 위치에 대한 날씨 정보를 얻기위한 흐름입니다. 지도가 업데이트되고 마커가 표시됩니다.

    2. 표시를 클릭하면 일기 예보 정보를 표시하는 정보 상자가 표시됩니다. 지시문을 사용하여지도 내부에 정보창을 생성합니다.

      app.directive("todayInfoDirective", function ($compile) { return { templateUrl: './src/views/infoBox.html', link: function(scope, element, attrs) { scope.city = scope.$eval(attrs.city); console.log(scope.city); } } });

    나는이 지시어 (scope.city) 내부에 데이터를 CONSOLE.LOG하기 위해 노력하고 내가 다른 위치 마커를 클릭 할 때마다 새로운 데이터가있다 볼 수 있습니다 : 이것은 내 코드입니다.

    캐시가 있고 모든 팝업에 동일한 콘텐츠가 있다고 생각합니다. 이 문제에 대한 생각이 있습니까? 내 응용 프로그램에 대한 링크입니다. beacots.com/wf/index.html

    고맙습니다.

  • 답변

    0

    내 서비스의 버그 때문이었습니다. 이전에는 다음과 같습니다

    app.factory('darkSkySvr', function ($http) { 
        var promise = null; 
        return function (lat, lng) { 
         promise = $http({ 
          cache: false, 
          method: 'GET', 
          url: 'http://api.thoitiethanoi.dev2.sutunam.com/forecast/' + lat + ',' + lng, 
         }) 
         return promise; 
        } 
    }) 
    
    : 나는이 코드 조각에 의해 업데이트

    app.factory('darkSkySvr', function($http) { 
        var promise = null; 
        return function(lat, lng) { 
         if(promise) { 
          return promise; 
         } 
         else { 
          promise = $http({ 
           cache: false, 
           method: 'GET', 
           url: 'http://api.thoitiethanoi.dev2.sutunam.com/forecast/' + lat + ',' + lng, 
          }) 
          return promise; 
         } 
        } 
    })