I'm using meteor and angular. Since I can't add modules after the angular bootstrap, I made a workaround and somewhat not satisfied with the way it was coded.
How can I improve this?:
(function() {
var controllers = ngMeteor.newControllers,
filters = ngMeteor.newFilters,
directives = ngMeteor.newDirectives,
services = ngMeteor.newServices
ngMeteor.config(function($controllerProvider) {
for (var prop in controllers) {
if (controllers.hasOwnProperty(prop)) {
$controllerProvider.register(prop, controllers[prop]);
}
}
});
ngMeteor.config(function($filterProvider) {
for (var prop in controllers) {
if (filters.hasOwnProperty(prop)) {
$filterProvider.register(prop, filters[prop]);
}
}
});
for (var prop in directives) {
if (directives.hasOwnProperty(prop)) {
ngMeteor.directive(prop, directives[prop]);
}
}
for (var prop in services) {
if (services.hasOwnProperty(prop)) {
ngMeteor.services(prop, services[prop]);
}
}
})();
The variables above will just have the same structure. For example:
/* Controllers */
ngMeteor.newControllers = {
MainCtrl: function($scope) {
// ...
},
SubCtrl: function($scope) {
// ...
}
};
}());
instead of})()
to remove ambiguity. – David Harkness Feb 6 at 4:25