mattslocum / ng-webworker

ng-webworker creates dynamic webworkers so angular apps can be multi-threaded.
MIT License
212 stars 31 forks source link

Unknown provider: ngWebworkerProvider <- ngWebworker #28

Open LoganLehman opened 8 years ago

LoganLehman commented 8 years ago

Hi @mattslocum,

I keep receiving an unknown provider error from ngWebworker. My inclusion is here:

 var app = angular.module('insight', [
    'ngAnimate',
    'ui.bootstrap',
    'ngWebworker',
    'ui.router',
    'ui.sortable',
    'ngTouch',
    'toastr',
    'smart-table',
    "xeditable",
    'ui.slimscroll',
    'ngJsTree',
    'pdf-viewer',
    'angular-progress-button-styles',
    'insight.theme',
    'insight.pages',
    'insight.widgets',
    'insight.factories'
])

From there I inject it into a controller:

 angular.module('insight.widgets')
    .controller('ExcelTableController', ExcelTableController)
    .directive('excelTable', excelTable)

/** @ngInject */
function ExcelTableController($scope, $window, $http, ngWebworker) {
    var vm = this;

    vm.data = [];
    vm.fullData = [];
    vm.sheets = [];
    vm.columnNames = {};
    vm.columns = {};
    vm.worker = ngWebworker.create(function(bstr) {
        return XLSX.read(bstr, {
            type: "binary"
        });
    })
........
........

I have also tried using the standard fashion instead of ngInject:

  angular.module('insight.widgets')
    .controller('ExcelTableController', ['$scope', '$window', '$http', 'ngWebworker', ExcelTableController])
    .directive('excelTable', excelTable)

/** @ngInject */
function ExcelTableController($scope, $window, $http, ngWebworker) {
    var vm = this;

    vm.data = [];
    vm.fullData = [];
    vm.sheets = [];
    vm.columnNames = {};
    vm.columns = {};
    vm.worker = ngWebworker.create(function(bstr) {
        return XLSX.read(bstr, {
            type: "binary"
        });
    })
........
........

and I am still having no luck.

Any ideas?

mattslocum commented 8 years ago

module 'insight' is different than module 'insight.widgets'. Try adding 'ngWebworker' to 'insight.widgets'.

LoganLehman commented 8 years ago

@mattslocum,

I already have. Still no luck. I am using wiredep in gulp to concatenate my bower components into one file, but for every other 3rd party library it has worked flawlessly.

BastienWW commented 7 years ago

Change: controller('ExcelTableController', ['$scope', '$window', '$http', 'ngWebworker', ExcelTableController])

To: controller('ExcelTableController', ['$scope', '$window', '$http', 'Webworker', ExcelTableController])