diff --git a/src/components/tabs/js/tabDirective.js b/src/components/tabs/js/tabDirective.js index 4dd7d40e5fb..79869f90502 100644 --- a/src/components/tabs/js/tabDirective.js +++ b/src/components/tabs/js/tabDirective.js @@ -103,7 +103,7 @@ function MdTab () { scope.select = scope.select || angular.noop; scope.deselect = scope.deselect || angular.noop; - scope.$watch('active', function (active) { if (active) ctrl.select(data.getIndex()); }); + scope.$watch('active', function (active) { if (active) ctrl.select(data.getIndex(), true); }); scope.$watch('disabled', function () { ctrl.refreshIndex(); }); scope.$watch( function () { diff --git a/src/components/tabs/js/tabsController.js b/src/components/tabs/js/tabsController.js index 525025cfd74..a7e82acd687 100644 --- a/src/components/tabs/js/tabsController.js +++ b/src/components/tabs/js/tabsController.js @@ -285,15 +285,16 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp } /** - * Update the selected index and trigger a click event on the original `md-tab` element in order - * to fire user-added click events. + * Update the selected index. Triggers a click event on the original `md-tab` element in order + * to fire user-added click events if canSkipClick or `md-no-select-click` are false. * @param index + * @param canSkipClick Optionally allow not firing the click event if `md-no-select-click` is also true. */ - function select (index) { + function select (index, canSkipClick) { if (!locked) ctrl.focusIndex = ctrl.selectedIndex = index; ctrl.lastClick = true; // skip the click event if noSelectClick is enabled - if (ctrl.noSelectClick) return; + if (canSkipClick && ctrl.noSelectClick) return; // nextTick is required to prevent errors in user-defined click events $mdUtil.nextTick(function () { ctrl.tabs[ index ].element.triggerHandler('click');