Answer the question
In order to leave comments, you need to log in
Why do I get ReferenceError: $http is not defined when working with "web worker"?
I implement work with the worker through services ('ng-vkThread', 'ngWebworker'), in this example - 'ngWebworker', but I get the same error: ReferenceError: $http is not defined
Help, what is the problem?
app.js
var app = angular.module('contactList', ['lumx','ngSanitize', 'ngCsv', 'ng-vkThread','ngWebworker']);
app.controller('ReadFileController', ['$scope','$http','vkThread','Webworker', function ($scope, $http, vkThread, Webworker) {
var foo = function (content) {
$http.post('/anguler-tasks-contacts/addContactData.php',{last_name:1, name:2, patronymic_name:3, address:4, telephone:5, url:6, description:7, completed:'false'}).then(function(response) {
$scope.contactslist.push({
id: response.data[0].id,
last_name: response.data[0].last_name,
name: response.data[0].name,
patronymic_name: response.data[0].patronymic_name,
address: response.data[0].address,
telephone: response.data[0].telephone,
url: response.data[0].url,
description: response.data[0].description,
completed: response.data[0].completed
});
});
return 1;
}
$scope.readContent = function($fileContent){
$scope.content = $fileContent;
var myWorker2 = Webworker.create(foo);
myWorker2.run($scope.content).then(function(result) {
console.log(result);
});
};
}]);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question