是否可以从全局的window
或window.angular
对象循环遍历我们创建并正在引导的所有控制器/模块/工厂等?循环遍历角度对象上的所有控制器
我想是这样的:
for(module in window.angular.modules) {
for(ctrl in module.controllers) {
console.log(ctrl);
}
for(factory in module.factories) {
console.log(factory);
}
...
}
目标:我要自动生成的,我们已经创建了应用中的一些文档。
编辑: 请注意,我们不在做控制器时创建全局对象。我们直接在模块上在注册它们:
angular.module('ourApp')
.controller('CustomerCtrl', ['$scope', function ($scope) { ... } ]);
也试着看看http://stackoverflow.com/questions/15250644/angularjs-loading-a-controller-dynamically – Whisher