0
我正在嘗試使用AngularJS開發一個Chrome擴展。我試圖做一個$ http.get()請求,在正常的HTML頁面正常工作,但在我的擴展中沒有這樣做,說500(請求失敗)錯誤。這裏是我的清單Angular Chrome擴展中的請求失敗錯誤
{
"name": "The Extension",
"manifest_version": 2,
"description": "A extension for chrome browsers",
"version": "1.0.0",
"background": {
"persistent": false,
"scripts": [
"background.js"
]
},
"permissions": [
"tabs", "<all_urls>"
]
}
我app.js(從background.js加載):
//This is adding base directive in app
var app = '<div class="my-extension"><div base></div></div>';
var wrapper = '<div ng-non-bindable>' + app + '</div>';
$('body').append(wrapper);
var myExtension = angular.module('my-extension', ['baseModule']);
window.name = '';
angular.bootstrap($('.my-extension')[0], ['my-extension']);
,BASE是:
var baseModule = angular.module('baseModule', []);
baseModule.directive('base', ['$http', function($http) {
return {
replace: true,
template: '<div>Hello World</div>',
link: function(scope, elem, attrs) {
$http({
method: 'GET',
url: 'http://api.example.com/api/yy/zz' //Sample API, Data is being got surely
}).then(function successCallback(response) {
console.log('success', response);
}, function errorCallback(response) {
console.log('error', response);
});
}
}
}]);
原諒我,如果這個問題是愚蠢的,我在擴展開發中相對超新。
我已經設置了所有的URL @wOxxOm,看我的清單。我應該覆蓋這一切的訪客 –
權限適用於擴展頁面,不適用於內容腳本或注入腳本。代碼在哪裏? – wOxxOm