Created
October 12, 2014 07:48
-
-
Save christophermina/740c5a5d4e549216acc9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
define([ | |
'/path/to/a/dependency' | |
], function(myDependcy) { | |
var module = angular.module('asyncModule', [myDependency.name]); | |
module.directive('asyncDirective', ['$http'', function($http) { | |
return { | |
link: function(scope, element, attrs) { | |
... Do stuff in our directive ... | |
} | |
} | |
}]); | |
return module; | |
}) |
This file contains hidden or 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
define([ | |
], function() { | |
var module = angular.module('mainApp'); | |
module.directive('parentDirective', ['$ocLazyLoad', function($ocLazyLoad) { | |
return { | |
link: function(scope, element, attrs) { | |
// This method called from user interaction | |
scope.loadAsyncModule = function () { | |
var self = this; | |
$ocLazyLoad.load({ | |
name: 'asyncModule', //Same name as defined in asyncmodule.js | |
files: ['/path/to/asyncdirective.js'] | |
}) | |
.then(function() { | |
//Our module is now fully loaded, we can use it as we would any other module | |
}); | |
} | |
}; | |
} | |
}]); | |
return module; | |
}) ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment