Кстати, оцените НОВЫЙ стайл ui 
 
var ui = window['ui'] = {
    name       : 'ui',
    children   : {},
    filters    : {},
    services   : {},
    directives : {},
    animations : {},
    controllers: {},
    init: function(element) {
        var $compile = this.service('$compile');
        var $scope = this.service('$scope');
        $compile(element)($scope);
    },
    module: function(name) {
    },
    directive: function(name, factory) {
    },
    service: function(name, factory) {
        return this.resource('services', name, factory);
    },
    filter: function(name, factory) {
        return this.resource('filters', name, factory);
    },
    animation: function(name, factory) {
        return this.resource('animations', name, factory);
    },
    controller: function(name, controller) {
        var $parseController = this.service('$parseController');
        if (controller) {
            this.controllers[name] = $parseController(controller);
            return this;
        }
        var controller = this.controllers[name];
        if (!controller) {
            controller = $parseController(window[name]);
        }
        return controller;
    },
    invoke: function(func, context, locals) {
        var self = this;
        if (!locals) {
            locals = {}
        }
        if (isArray(func)) {
            var inject = func.slice();
            func = inject.pop();
            func['$inject'] = inject;
        }
        if (!func['$inject']) {
            var params = func.toString().match(/\(([\s\S]*?)\)/)[1].match(/[\w$]+/img) || [];
            func['$inject'] = params;
        }
        locals['$module'] = this;
        var services = func['$inject'].map(function(injectName) {
            return locals[injectName] || self.service(injectName);
        });
        return func.apply(context, services);
    },
    instantiate: function(func, locals) {
        var instance = Object.create(func.prototype);
        var returns = this.invoke(func, instance, locals);
        if (isObject(returns)) {
            instance = returns;
        }
        return instance;
    },
    resource: function(type, name, factory) {
        if (factory) {
            var resource = {
                factory : factory,
                instance: null
            };
            this[type][name] = resource;
            return this;
        }
        var resource = this[type][name];
        if (!resource) return null;
        var instance = resource.instance;
        if (!instance) {
            var instance = this.invoke(resource.factory) || null;
            resource.instance = instance;
        }
        return instance;
    }
};