text: /**
   * @ngdoc overview
   * @name material.services.registry
   *
   * @description
   * A component registry system for accessing various component instances in an app.
   */
  angular.module('material.services.registry', [])
    .factory('$materialComponentRegistry', [ '$log', materialComponentRegistry ]);
  
  /**
   * @ngdoc service
   * @name material.services.registry.service:$materialComponentRegistry
   *
   * @description
   * $materialComponentRegistry enables the user to interact with multiple instances of
   * certain complex components in a running app.
   */
  function materialComponentRegistry($log) {
    var instances = [];
  
    return {
      /**
       * Used to print an error when an instance for a handle isn't found.
       */
      notFoundError: function(handle) {
        $log.error('No instance found for handle', handle);
      },
      /**
       * Return all registered instances as an array.
       */
      getInstances: function() {
        return instances;
      },
  
      /**
       * Get a registered instance.
       * @param handle the String handle to look up for a registered instance.
       */
      get: function(handle) {
        var i, j, instance;
        for(i = 0, j = instances.length; i < j; i++) {
          instance = instances[i];
          if(instance.$$materialHandle === handle) {
            return instance;
          }
        }
        return null;
      },
  
      /**
       * Register an instance.
       * @param instance the instance to register
       * @param handle the handle to identify the instance under.
       */
      register: function(instance, handle) {
        instance.$$materialHandle = handle;
        instances.push(instance);
  
        return function deregister() {
          var index = instances.indexOf(instance);
          if (index !== -1) {
            instances.splice(index, 1);
          }
        };
      },
    }
  }
  
  