I have angular working fine for the front end popup of my chrome extension but I need the background script to do an ajax request and I cannot even begin to think how I can get angular's $http there.
Specifically I will be responding with the ajax result from a call to the chrome API "chrome.runtime.sendMessage".
So currently I have my listener wired up in the background.js
var someData="TESTDATA";
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
sendResponse(someData);
});
and what I want is
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
$http({
method: 'GET',
url: "http://autocomplete.wunderground.com/' +
'aq?query=" +
'query'
}).success(function(data) {
sendResponse(data.RESULTS);
}).error(function(err) {
console.log(err);
});
});
which obviously does not work even though angular.js is in the manifest file for the background.
How can I use the angular $http object in this setup? (I do not have an html page for the background.js)
$http? Why not just a standard XHR request?