如何从chrome.storage获取数据后运行angularjs引擎?
我在app.js
中有这段代码:
'use strict';
var host = '';
var port = '';
chrome.storage.sync.get({
host: '',
port: '',
}, function(items) {
host = items.host;
port = items.port;
});
// need to run this line after data is retrived from chrome.storage
var app = angular.module('TouchApp', ['TouchApp.services', 'TouchApp.controllers', 'TouchApp.directives']);
chrome获取数据后,运行angularjs引擎。
任何解决方案?
答案 0 :(得分:1)
回调的目的是在异步功能完成后运行。所以你需要把代码放在那里。
var app;
chrome.storage.sync.get({
host: '',
port: '',
}, function(items) {
host = items.host;
port = items.port;
app = angular.module('TouchApp', ['TouchApp.services', 'TouchApp.controllers', 'TouchApp.directives']);
});