Created
December 30, 2015 01:55
-
-
Save jack4it/da9e699d7e6968b210be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class SystemLazyLoadService { | |
static $inject = ["$ocLazyLoad"]; | |
constructor($ocLazyLoad) { | |
this.$ocLazyLoad = $ocLazyLoad; | |
} | |
load(src, moduleExportKey) { | |
let loader = this.$ocLazyLoad; | |
return System.import(src) | |
.then(module => { | |
var angularModule = module[moduleExportKey || 'default']; | |
if (!angularModule) { | |
console.info(module); | |
throw new Error("Unexpected angular module"); | |
} | |
return loader.load(angularModule); | |
}) | |
.then(() => { | |
return null; // !!! critical here; this is needed to trick future state infra | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment