Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
fix(tabs): re-adds disconnected scopes for tab content
Browse files Browse the repository at this point in the history
Note: This may open up some temporary bugs while fine-tuning the logic
  • Loading branch information
Robert Messerle committed May 27, 2015
1 parent f4c30ce commit e6f19d4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/tabs/js/tabsDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ function MdTabs ($mdTheming, $mdUtil, $compile) {
ng-repeat="(index, tab) in $mdTabsCtrl.tabs" \
md-template="tab.template"\
md-scope="tab.parent"\
ng-if="tab.isActive()"\
md-connected-if="tab.isActive()"\
ng-class="{\
\'md-no-transition\': $mdTabsCtrl.lastSelectedIndex == null,\
\'md-active\': tab.isActive(),\
Expand Down
21 changes: 19 additions & 2 deletions src/components/tabs/js/templateDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,36 @@ angular
.module('material.components.tabs')
.directive('mdTemplate', MdTemplate);

function MdTemplate ($compile) {
function MdTemplate ($compile, $mdUtil, $timeout) {
return {
restrict: 'A',
link: link,
scope: {
template: '=mdTemplate',
compileScope: '=mdScope'
compileScope: '=mdScope',
connected: '=?mdConnectedIf'
},
require: '^?mdTabs'
};
function link (scope, element, attr, ctrl) {
if (!ctrl) return;
var connected = true;
element.html(scope.template);
$compile(element.contents())(scope.compileScope);
$timeout(handleScope);
function handleScope () {
scope.$watch('connected', function (value) { value ? disconnect() : reconnect(); });
scope.$on('$destroy', reconnect);
}
function disconnect () {
if (!connected) return;
$mdUtil.disconnectScope(scope.compileScope);
connected = false;
}
function reconnect () {
if (connected) return;
$mdUtil.reconnectScope(scope.compileScope);
connected = true;
}
}
}
5 changes: 5 additions & 0 deletions src/components/tabs/tabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ md-tabs {
padding-bottom: 11px;
}
}
&:not([md-dynamic-height]) {
md-tabs-content-wrapper {
top: $tabs-header-height + 1;
}
}
}
}
md-tabs-wrapper {
Expand Down

0 comments on commit e6f19d4

Please sign in to comment.