I know, the name isn't obvious...
DEMO TIME !
Better, faster, faster
My cousin knows a guy who does it with the providers and...
$ocLazyLoad.load({
name: 'TestModule',
files: ['testModule.js']
}).then(function(data) {
// do what you want
});
$stateProvider.state('index', {
url: "/",
controller: 'AppCtrl'
resolve: {
loadMyCtrl: ['$ocLazyLoad', function($ocLazyLoad) {
// you can lazy load files for an existing module
return $ocLazyLoad.load({
name: 'app',
files: ['js/AppCtrl.js']
});
}]
}
});
<div oc-lazy-load="{name: 'TestModule', files: ['js/testModule.js']}">
<!-- Use a directive from TestModule -->
<test-directive></test-directive>
</div>
angular.module('MyModule', [{
name: 'pascalprecht.translate',
files: ['vendor/angular-translate.js']
}]
).controller('MyCtrl', function($translate) {
this.love = $translate.instant('<3');
});
I'm working on it (once I'm legend in Hearthstone)