ocombe / ocLazyLoad

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

Error when injecting module dependency #257

Open hugomn opened 9 years ago

hugomn commented 9 years ago

Looks like textAngular still having problems with ocLazyLoad. I'm using textAngular 1.4.6 with ocLazyLoad 1.0.6. I've configured textAngular module in ocLazyLoad config:

    .config(['$ocLazyLoadProvider', function($ocLazyLoadProvider) {
      $ocLazyLoadProvider.config({
          debug:  true,
          events: true,
          modules: [{
              name: 'textAngular',
              files: [
                  'libs/angular/textAngular/dist/textAngular-rangy.min.js',
                  'libs/angular/textAngular/dist/textAngular.min.js',
                  'libs/angular/textAngular/dist/textAngular.css'
              ]
          }]
      });
    }])

And in my router configuration:

.state('my.route', {
                    url: '/route',
                    controller: 'MyController',
                    templateUrl: 'tpl/myroute.html',
                    params: { event: null },
                    resolve: {
                        loadTextAngular: ['$ocLazyLoad', function ($ocLazyLoad) {
                            return $ocLazyLoad.load('textAngular');
                        }],
                        loadMyCtrl: ['$ocLazyLoad', 'loadTextAngular', function ($ocLazyLoad, loadTextAngular) {
                            return $ocLazyLoad.load({
                                files: ['js/controllers/MyController.js']
                            });
                        }]
                    }
                })

And I'm getting this error:

[$injector:unpr] Unknown provider: taSelectionProvider <- taSelection
http://errors.angularjs.org/1.4.3/$injector/unpr?p0=taSelectionProvider%20%3C-%20taSelection

If I include the textAngular files in my index.html and load the module in my app configuration, everything works fine. Maybe some circular dependency in textAngular?

maxavi commented 8 years ago

+1 for me, I have the same issue. Strangely enough it sometimes works by random page refreshes. I guess it has to do with some order of execution/loading.

I added the ocLazyLoad logs in both cases

working.txt notworking.txt

alo commented 8 years ago

+1

johansten commented 8 years ago

I've gotten the past the dependency loading error by adding a dependency of textAngular.DOM to textAngularSetup. But now when I'm ocLazyLoading, the textAngular module can't access the values set up in the textAngularSetup module (e.g., 'taTools'), I just get empty objects injected

+1

mort3za commented 8 years ago

This comment is the solution. Just change forceTextAngularSanitize: true to forceTextAngularSanitize: false in textAngularSetup.js or change it by $provide in config section.