ocLazyLoad icon indicating copy to clipboard operation
ocLazyLoad copied to clipboard

point people to Angular 1.6.7 and $injector.loadNewModules(modules)

Open graingert opened this issue 6 years ago • 9 comments

see https://github.com/angular/angular.js/commit/6e78fee73258bb0ae36414f9db2e8734273e481b

$injector.loadNewModules(modules)

graingert avatar Nov 27 '17 10:11 graingert

@ocombe might be worth deprecating ocLazyLoad?

graingert avatar Nov 27 '17 10:11 graingert

How to declarate modules in bundleUrl ? Like a simple angular module or do you need to export this module ?

Insidexa avatar Dec 10 '17 12:12 Insidexa

app.factory('loadModule', function($injector, $q) {
  return function loadModule(moduleName, bundleUrl) {
    return $q.resolve(import('./path/to/es/module')).then(function(v) { $injector.loadNewModules([v.default]); });
  };
})

graingert avatar Dec 10 '17 12:12 graingert

Is there an implementation of directives for that feature?

BusbyActual avatar Oct 02 '19 00:10 BusbyActual

@BusbyActual what?

graingert avatar Oct 02 '19 00:10 graingert

You advocated for suggesting this library is deprecated and to suggested to use the $injector.loadNewModules method. How would one load a directive ?

BusbyActual avatar Oct 02 '19 00:10 BusbyActual

@BusbyActual you declare the directive in the module you want to load

graingert avatar Oct 02 '19 01:10 graingert

@graingert

Previously compiled HTML will not be affected by newly loaded directives, filters and components.

If I'm reading this correctly directives will still be an issue.

BusbyActual avatar Oct 03 '19 20:10 BusbyActual

Just make sure you compile html in loadModule(...).then(moduleName => { /* here */ })

graingert avatar Oct 03 '19 20:10 graingert