Angularjs ocLazyLoad是否可以用于扩充控制器并访问其作用域?
我想我可能可以使用ocLazyLoad来解决我的问题,但无法从文档中轻松确定。我想这样做:Angularjs ocLazyLoad是否可以用于扩充控制器并访问其作用域?,angularjs,oclazyload,Angularjs,Oclazyload,我想我可能可以使用ocLazyLoad来解决我的问题,但无法从文档中轻松确定。我想这样做: MyApp.controller('page', ['$scope','$http', 'socketManager', '$ocLazyLoad', function ($scope, $http, socketManager, $ocLazyLoad) { // Get custom content (list of devices) $scope.GetDevices = func
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);
})
})
}
}])
$ocLazyLoadProvider.config({
modules: [{
name: 'DeviceType1',
files: ['js/DeviceType1.js','views/partials/DeviceType1.html']
}],
// more devices
});
模块定义如下:
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);
})
})
}
}])
$ocLazyLoadProvider.config({
modules: [{
name: 'DeviceType1',
files: ['js/DeviceType1.js','views/partials/DeviceType1.html']
}],
// more devices
});
我的问题是,一旦模块加载,它在哪里加载?延迟加载的javascript是否可以访问$scope、$http和socketManager?另外,如果我包含html文件,它是否作为控制器的一部分呈现?$ocLazyLoad通常用于在运行控制器之前加载代码。$ocLazyLoad通常用于在运行控制器之前加载代码。