ocombe / ocLazyLoad

Lazy load modules & components in AngularJS
https://oclazyload.readme.io
MIT License
2.63k stars 510 forks source link

Initialize before loading as dependency #348

Open udayms opened 8 years ago

udayms commented 8 years ago

Hi... I am trying to test the agGrid component in my project. I already have a running setup of ocLazyLoad working fine in my project. Typically, I define the modules in a config file and then load that config in my ui-router. But, agGrid documentation wants me to register the library as a angular module before I load it as a dependency.

// get ag-Grid to create an Angular module and register the ag-Grid directive agGrid.initialiseAgGridWithAngular1(angular); // create your module with ag-Grid as a dependency var module = angular.module("example", ["agGrid"]);

How can I do this?

tsukihimeNyo commented 7 years ago

I encounter the same issue. Hope someone can help.

tsukihimeNyo commented 7 years ago

Just solve the problem by adding the agGrid.initialiseAgGridWithAngular1(angular) before return $ocLazyLoad.load ,

            resolve: {
                loadPlugin: function ($ocLazyLoad) {
                    agGrid.initialiseAgGridWithAngular1(angular);
                    return $ocLazyLoad.load([
                        {
                            name: 'agGrid',
                            files: ['js/plugins/ag-grid/ag-grid.min.js']
                        }
                    ]);
                }
            }