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

Commit

Permalink
fix(tabs): resolves issue with nested tabs
Browse files Browse the repository at this point in the history
Closes #4989
  • Loading branch information
Robert Messerle committed Nov 16, 2015
1 parent fe84405 commit c0fcb87
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/components/tabs/js/tabDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ function MdTab () {
require: '^?mdTabs',
terminal: true,
compile: function (element, attr) {
var label = element.find('md-tab-label'),
body = element.find('md-tab-body');
var label = firstChild(element, 'md-tab-label'),
body = firstChild(element, 'md-tab-body');

if (label.length == 0) {
label = angular.element('<md-tab-label></md-tab-label>');
Expand Down Expand Up @@ -88,8 +88,8 @@ function MdTab () {
function postLink (scope, element, attr, ctrl) {
if (!ctrl) return;
var index = ctrl.getTabElementIndex(element),
body = element.find('md-tab-body').eq(0).remove(),
label = element.find('md-tab-label').eq(0).remove(),
body = firstChild(element, 'md-tab-body').remove(),
label = firstChild(element, 'md-tab-label').remove(),
data = ctrl.insertTab({
scope: scope,
parent: scope.$parent,
Expand All @@ -114,6 +114,14 @@ function MdTab () {
}
);
scope.$on('$destroy', function () { ctrl.removeTab(data); });
}

function firstChild (element, tagName) {
var children = element[0].children;
for (var i = 0, len = children.length; i < len; i++) {
var child = children[i];
if (child.tagName === tagName.toUpperCase()) return angular.element(child);
}
return angular.element();
}
}

0 comments on commit c0fcb87

Please sign in to comment.