2016-12-07 10 views
0

リクエストを送信する角度スクリプトがあります。フォームjsonで答えを入手してください。定期的にお問い合わせを送信するには? ? どうzhsonの受領に関するデータ、インターネット上にあるアプリのアイコンの画像を、使用するために `動的opdateアイコンのクロム拡張子

var app = angular.module('jsbin', ['ngAnimate']); 
 
app.controller('DemoCtrl', function($http,$scope) { 
 
    var vm = this; 
 
    var temp1=[]; 
 
var URL2=[]; 
 
    var URL = 'http://api.openweathermap.org/data/2.5/forecast/daily'; 
 
var showSwitch=false; 
 
    var request = { 
 
    method: 'GET', 
 
    url: URL, 
 
    params: { 
 
     q: localStorage["var"], 
 
     mode: 'json', 
 
     units: localStorage["SystemOfNumbers"], 
 
     cnt: '7', 
 
     appid: '3ac1f68b653ffbf72a5f782420062771' 
 
    } 
 
    }; 
 
var showMe=false; 
 

 

 

 
    $scope.myFunc=function() { 
 
     $scope.showMe=!$scope.showMe; 
 
      } 
 

 

 
      var range = []; 
 
      for(var i=0;i<7;i++) { 
 
      range.push(i); 
 
      } 
 
      $scope.range = range; 
 

 

 
      $scope.colorFont=function(templiche){ 
 
      if (templiche>0) return 'red'; 
 
      else { 
 
       return 'blue'; 
 
      } 
 
     } 
 

 

 
$http(request) 
 
    .then(function(response) { 
 
    vm.data = response.data; 
 
    vm.URL2="http://openweathermap.org/img/w/"+vm.data.list[0].weather[0].icon+".png"; 
 
    vm.mmrts=Math.round(vm.data.list[0].pressure* 0.7500); 
 
    vm.symbal=localStorage["Symbal"]; 
 

 

 
     }). 
 
    catch(function(response) { 
 
     vm.data = response.data; 
 
     vm.URL2="http://openweathermap.org/img/w/"+vm.data.list[0].weather[0].icon+".png"; 
 
    vm.symbal=localStorage["Symbal"]; 
 
    }); 
 

 
} 
 

 
);
{ 
 
\t "manifest_version" : 2, 
 
\t "name" : "...", 
 
\t "short_name" : "...", 
 
\t "version" : "1.0", 
 
\t "author" : "...", 
 
\t "description" : "...", 
 

 
\t "icons" : { 
 
\t \t "16" : "http://openweathermap.org/img/w/13d.png", 
 
\t \t "32" : "http://openweathermap.org/img/w/13d.png", 
 
\t \t "48" : "http://openweathermap.org/img/w/13d.png", 
 
\t \t "64" : "icons/64x64.png", 
 
\t \t "128" : "icons/128x128.png" 
 
\t }, 
 

 
\t "content_scripts": [ 
 
    { 
 
     "matches": [ "*://*/*" ], 
 
     "js": [ "weather.js" ] 
 
    } 
 
    ], 
 

 
\t "background" : { 
 

 
\t }, 
 
\t "permissions": [ 
 
      "storage","activeTab" 
 
     ], 
 

 
    "browser_action": { 
 
     "default_title": "...", 
 
     "default_icon": "icons/water.png", 
 
\t \t "default_popup": "popup.html" 
 
    } 
 
}

そしてフォーマットアドレスアイコン:」http://openweathermap.org/img/w/ {{[item.weather 0] .icon}} .png "

答えて

0

setIcon methodでアイコンを動的に変更できます。たとえば:

chrome.browserAction.setIcon({path:'https://example.com/image.png'}); 

定期的にリクエストを送信するには、background pageを作成し、alarm APIを使用する必要があります。

関連する問題