Skip to content

Commit

Permalink
Merge pull request #11 from tlvince/bug/active-inactive
Browse files Browse the repository at this point in the history
Switch tabs iif tab state is inactive, closes #10
  • Loading branch information
rpocklin committed Feb 5, 2015
2 parents ca33027 + 673f408 commit 752054b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/ui-router-tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ angular.module('ui.router.tabs').directive('tabs', ['$rootScope', '$state',
// if none are active, set the default
$scope.current_tab = $scope.current_tab || $scope.tabs[0];
$scope.go($scope.current_tab.route, $scope.current_tab.params, $scope.current_tab.options);

$scope.changeTab = function(tab) {
if (tab.route !== $scope.current_tab.route) {
$scope.go(tab.route, tab.params, tab.options);
}
};
}],
templateUrl: function(element, attributes) {
return attributes.templateUrl || 'ui-router-tabs-default-template.html';
Expand All @@ -92,9 +98,7 @@ angular.module('ui.router.tabs').directive('tabs', ['$rootScope', '$state',
function($templateCache) {
var DEFAULT_TEMPLATE = '<div>' +
'<tabset class="tab-container" type="{{type}}" vertical="{{vertical}}" justified="{{justified}}">' +
' <tab class="tab" ng-repeat="tab in tabs" heading="{{tab.heading}}" ui-sref="{{tab.route}}(tab.params)"' +
' ui-sref-opts="{{tab.options}}" ng-click active="tab.active">' +
' </tab>' +
' <tab class="tab" ng-repeat="tab in tabs" heading="{{tab.heading}}" active="tab.active" ng-click="changeTab(tab)" />' +
'</tabset>' +
'</div>';

Expand Down

0 comments on commit 752054b

Please sign in to comment.