저는 angluarJS를 사용하여 크롬 확장 프로그램에서 작업하고 있습니다. 이제 완전히 두뇌를 불 태우는 문제가 있습니다.
데이터를 가져 와서 해당 데이터를 구문 분석하고 구문 분석 된 데이터를 백그라운드 페이지의 localStorage에 저장하고 브라우저 조치시 해당 데이터를 가져 와서 팝업 html에 표시하려고합니다. 이제
을 파고 저장하고 데이터를 반복적으로 저장하려는 경우 http://developer.chrome.com/extensions/alarms.html과 같이 chrome.alarms API를 사용하지만 제대로 작동하지 않습니다.chrome.alarms api가 angularJS와 함께 제대로 작동하지 않습니다.
app.controller('bgCtrl', function AlfredCtrl($scope, courseService) {
var setLocal = function(){
console.log("fired inside setLocal(), but out of getCourses()");
courseService.getCourses().then(function (events){
console.log("fired inside of getCourses()");
localStorage.setItem("deadlines", JSON.stringify(events.deadlines));
})
};
var delay = 1 ;
chrome.alarms.create("scheduleRequest", {periodInMinutes: delay});
chrome.alarms.onAlarm.addListener(function(alarm){
if(alarm.name == "scheduleRequest"){
console.log("fired out of setLocal()");
setLocal();
}
});
});
함수 getCourses은() BG의 서비스에서 반환됩니다
여기에 배경 컨트롤러에 내 코드입니다. 호출 될 때 파싱 된 데이터를 반환합니다. 내가 크롬 개발 도구에서 검사 할 때
, 그것은 반복적으로 표시
all.That에서 callec되지 않은 기능 courseService.getCourses를()라고하는 것입니다fired out of setLocal(). bgCtrl.js:32
fired inside setLocal(), but out of getCourses(). bgCtrl.js:7
내가 가지고있는 문제입니다.
도와주세요!
아직도이 질문에 흥미가 있습니까? – Xan
나는 그것에 매우 흥미가있다. – saric