Angularjs 如何使用angular在web worker中使用作用域
这是我的密码。但是我得到了错误。请在这个问题上帮助我 内部控制器Angularjs 如何使用angular在web worker中使用作用域,angularjs,Angularjs,这是我的密码。但是我得到了错误。请在这个问题上帮助我 内部控制器 if(typeof(Worker) !== "undefined") { if(typeof(worker) == "undefined") { var worker = new Worker("assets/scripts/directives/custommultifilter.js"); worker.postMessage({ "getobject":scope.payloadRow
if(typeof(Worker) !== "undefined") {
if(typeof(worker) == "undefined") {
var worker = new Worker("assets/scripts/directives/custommultifilter.js");
worker.postMessage({ "getobject":scope.payloadRowCollection});
worker.onmessage = function(event) {
console.log(event);
}
}
}
在web worker中(custommultifilter.js)
不可能在web工作人员和“主”脚本之间共享变量。如果是,您将遇到并发问题 但您可以通过事件进行沟通:
// in the worker
self.postMessage('someData);
// in angular
worker.addEventListener('message', function(e) {
console.log('Worker said: ', e.data);
}, false);
这是一个关于网络工作者的好教程。
这是我的代码。。。请帮忙。。。对不起,它不是那样工作的。尽可能清楚简洁地解释您的问题。我想在WebWorker(custommultifilter.js)中使用$filter('filter')函数。
// in the worker
self.postMessage('someData);
// in angular
worker.addEventListener('message', function(e) {
console.log('Worker said: ', e.data);
}, false);