I'm currently using Zurb Foundation 4 for my CSS/Grid Framework and they have a really nice Tab Control. However, when it is on a page that is loaded via ng-view the tab control doesn't work right.
So, I'd thought I'd write my own directive since I will be using this across our site. However, once I got into it I soon realized I was in over my head.
I've provided an example of what I am trying to do and then an example of my actual mess of code
Static example: Here is what I am trying to accomplish. See full code example on JsFiddle. http://jsfiddle.net/aYTaN/1/
<div class="tab-container">
<p class="active-tab">
<a href="">Tasks</a>
</p>
<p>
<a href="">Parts</a>
</p>
<section>
Tab 1 content
</section>
<section style="display:none">
Tab 2 Content
</section>
</div>
Here's the actual code I have that is not working: http://jsfiddle.net/dxwc9/3/
app.directive('tabControl', function($rootScope) {
'use strict';
return {
restrict: 'E',
link: function(scope, element, attrs) {
console.log(attrs.tabs);
var tabs = attrs.tabs.split(',');
var tabContainer = angular.element('<div class="tab-container"></div>'),
tab = angular.element('<p><a href=""></a></p>'),
content = angular.element('<section></section>');
for (var i = 0; i<tabs.length; i++){
tabContainer.append(tab);
var title = tab.find('a');
title.html(tabs[i]);
tabContainer.append(content);
}
}
}
});
I would really appreciate any help please.
Thank you,
Chris