ocLazyLoad icon indicating copy to clipboard operation
ocLazyLoad copied to clipboard

Load config after injection

Open VictorJuliani opened this issue 8 years ago • 1 comments

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

VictorJuliani avatar Oct 20 '16 12:10 VictorJuliani

I'm having the same issue with hotkeysProvider, I couldn't lazy load it.

sibelly avatar Jun 08 '17 21:06 sibelly