ocombe / ocLazyLoad

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

Load config after injection #356

Open VictorJuliani opened 7 years ago

VictorJuliani commented 7 years ago

I want to run a config method when lazy loading a module. After requesting and injecting my modules, my app loads a file with my config content which gets correctly (or not?) executed and updates the provider. But when I call the service in a controller it's like no config was made.

This is how plugins are loaded:

.state('scheduler', {
        url: '/scheduler',
        templateUrl: '/views/marketplace/scheduler.html',
        controller: 'SchedulerCtrl',
        resolve: {
            loadScheduler: ['$ocLazyLoad', function($ocLazyLoad) {
                return $ocLazyLoad.load(['moment', 'scheduler']);
            }]
        }
    });
{
             name: 'moment',
             insertBefore: '#loadJS',
             files: ['/js/moment-with-locales.js']
       },
       {
           name: 'scheduler',
           insertBefore: '#loadJS',
           serie: true,
           files: ['/js/tmhDynamicLocale.js', '/js/ng-weekly-scheduler.js', '/js/scheduler.js']
       }

Whereas my scheduler.js file referenced above:

angular.module('eXperting')
.config(['weeklySchedulerLocaleServiceProvider', function (localeServiceProvider) {
    localeServiceProvider.configure({
      doys: {'pt-br': 4},
      lang: {'pt-br': {month: 'Mês', weekNb: 'Semana', addNew: 'Novo item'}},
      localeLocationPattern: '/js/angular-locale_{{locale}}.js'
    });
}]);

Finally, my controller declaration:

.controller('SchedulerCtrl', ['$scope', 'weeklySchedulerLocaleService', function ($scope, localeService)

I can make it work by importing the js files manually though Githubissues.

  • Githubissues is a development platform for aggregating issues.