code: function(instance, handle) {
          if (!handle) return angular.noop;
  
          instance.$$mdHandle = handle;
          instances.push(instance);
          resolveWhen();
  
          return deregister;
  
          /**
           * Remove registration for an instance
           */
          function deregister() {
            var index = instances.indexOf(instance);
            if (index !== -1) {
              instances.splice(index, 1);
            }
          }
  
          /**
           * Resolve any pending promises for this instance
           */
          function resolveWhen() {
            var dfd = pendings[handle];
            if (dfd) {
              dfd.forEach(function (promise) {
                promise.resolve(instance);
              });
              delete pendings[handle];
            }
          }
        }
docs: Register an instance.
  @param instance the instance to register
  @param handle the handle to identify the instance under.