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 where md-tabs is used within ui-view by…
Browse files Browse the repository at this point in the history
… removing hard requirement for `md-tabs` controller

This merely prevents an error from being fired if child directives are parsed without the expected parent controller.  This seems to be an issue with `ui-router`; however, including this fix on our end shouldn't hurt anything.

Closes #2414
  • Loading branch information
Robert Messerle committed Apr 20, 2015
1 parent aff50d5 commit 4350803
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/components/tabs/js/labelTemplateDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
restrict: 'A',
link: link,
scope: { template: '=mdLabelTemplate' },
require: '^mdTabs'
require: '^?mdTabs'
};
function link (scope, element, attr, ctrl) {
if (!ctrl) return;
var index = scope.$parent.$index;
scope.$watch('template', function (html) {
element.html(html);
Expand Down
3 changes: 2 additions & 1 deletion src/components/tabs/js/tabDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

function MdTab () {
return {
require: '^mdTabs',
require: '^?mdTabs',
terminal: true,
scope: {
label: '@',
Expand All @@ -74,6 +74,7 @@
};

function postLink (scope, element, attr, ctrl) {
if (!ctrl) return;
var tabs = element.parent()[0].getElementsByTagName('md-tab'),
index = Array.prototype.indexOf.call(tabs, element[0]),
data = ctrl.insertTab({
Expand Down
3 changes: 2 additions & 1 deletion src/components/tabs/js/tabItemDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
.directive('mdTabItem', MdTabItem);

function MdTabItem () {
return { require: '^mdTabs', link: link };
return { require: '^?mdTabs', link: link };
function link (scope, element, attr, ctrl) {
if (!ctrl) return;
ctrl.attachRipple(scope, element);
}
}
Expand Down

0 comments on commit 4350803

Please sign in to comment.