我用来创建Chrome应用的Angular JS的新功能。
任何人都知道如何在chillax.breakInterval
回调函数中访问chrome.storage.sync.get
(以及“chillax”的其他属性)?
angular.module('ChillaxApp', [])
.controller("ChillaxController", function () {
var chillax = this;
chillax.init = function() {
var settings = {};
settings["enabled"] = "";
settings["reminderInterval"] = "";
settings["breakInterval"] = "";
settings["sound"] = "";
chrome.storage.sync.get(settings, function(obj) {
// Setting these variables here aren't available within the controller
chillax.reminderInterval = obj["reminderInterval"];
chillax.breakInterval = obj["breakInterval"];
chillax.sound = obj["sound"];
});
};