I think I may be able to use ocLazyLoad to solve my problem, but couldn't easily determine from the documentation. I would like to do something like this:
MyApp.controller('page', ['$scope','$http', 'socketManager', '$ocLazyLoad',
function ($scope, $http, socketManager, $ocLazyLoad) {
// Get custom content (list of devices)
$scope.GetDevices = function () {
$http({method: "get",url: "/api/devices"})
.success(function (devices) {
// Load the module(s) for this
devices.foreach(function () {
$ocLazyLoad.load(devices.module);
})
})
}
}])
With modules defined something like this:
$ocLazyLoadProvider.config({
modules: [{
name: 'DeviceType1',
files: ['js/DeviceType1.js','views/partials/DeviceType1.html']
}],
// more devices
});
My question is once the module(s) is loaded, where is it loaded? Will the lazy loaded javascript have access to $scope, $http and socketManager? Also, if I include html files, is it rendered as part of the controller?