code: function insertTab (tabData, index) {
      var hasLoaded = loaded;
      var proto = {
            getIndex:     function () { return ctrl.tabs.indexOf(tab); },
            isActive:     function () { return this.getIndex() === ctrl.selectedIndex; },
            isLeft:       function () { return this.getIndex() < ctrl.selectedIndex; },
            isRight:      function () { return this.getIndex() > ctrl.selectedIndex; },
            shouldRender: function () { return !ctrl.noDisconnect || this.isActive(); },
            hasFocus:     function () {
              return ctrl.styleTabItemFocus
                  && ctrl.hasFocus && this.getIndex() === ctrl.focusIndex;
            },
            id:           $mdUtil.nextUid(),
            hasContent: !!(tabData.template && tabData.template.trim())
      };
      var tab = angular.extend(proto, tabData);
  
      if (angular.isDefined(index)) {
        ctrl.tabs.splice(index, 0, tab);
      } else {
        ctrl.tabs.push(tab);
      }
      processQueue();
      updateHasContent();
  
      $mdUtil.nextTick(function () {
        updatePagination();
        setAriaControls(tab);
  
        // if autoselect is enabled, select the newly added tab
        if (hasLoaded && ctrl.autoselect) {
          $mdUtil.nextTick(function () {
            $mdUtil.nextTick(function () { select(ctrl.tabs.indexOf(tab)); });
          });
        }
      });
      return tab;
    }
docs: Create an entry in the tabs array for a new tab at the specified index.
  @param {Object} tabData tab to insert
  @param {number} index location to insert the new tab
  @returns {Object} the inserted tab