I've created a tab control using angular directives. It is consist of tab, tab-item directives with new scope and tab-item-header, tab-item-body directives for which scope is not declared.
If I understand correctly these directives use scope of tab-item directive because they are placed inside it. But when I try to get in markup property index which is declared inside tab-item scope it is undefined.
app.directive('tabItemHeader', function(){
return {
require: '^tabItem',
transclude: true,
template: '<div ng-click="$parent.setCurrentTab(index)" ng-transclude></div>',
};});
app.directive('tabItemBody', function(){
return {
require: '^tabItem',
transclude: true,
template: '<div ng-show="index==$parent.currentTabIndex"><div ng-transclude></div></div>'
};});
I've created a plunk http://plnkr.co/edit/HkXIOt8FKMw4Ja2GZtF1?p=preview to demonstrate it.
What is wrong?