I have the following problem. I use angularJS in the chrome extension, in the popup. I would like to get the url of the tab and display it in the popup. For getting the url I use:
var link;
var query = { active: true, currentWindow: true };
function callback(tabs) {
var currentTab = tabs[0];
var url = currentTab.url;
console.log('URL: ' + url);
link = url
}
chrome.tabs.query(query, callback);
$scope.link = link;
console.log('URL AFTER THE CALL: ' + $scope.link);
This is the code of the MainController that controls popup. I would like to use the url in the popup.html using the $scope.link variable, but I get data only inside of the callback function. The output looks like this:
URL AFTER THE CALL: undefined
URL: http://stackoverflow.com/questions/ask?title=angular%20js%20url%20in%20popup
So it looks like the link assignment and console log 'After call' is executed before the callback function is executed... I do not know how to handle this.