twitter bootstrap - Tabs not working in Single Page Application with AngularJS -
i have "edit" view need display tabs separate different information needed. found site discusses creation of directive catch tab changing. first directive , not working. when click on second tab, takes me default view. not sure have implemented incorrectly.
web page -
<ul class="nav nav-tabs"> <li class="active"><a showtab="" href="#home">home</a></li> <li><a showtab="" href="#menu1">menu 1</a></li> <li><a showtab="" href="#menu2">menu 2</a></li> <li><a showtab="" href="#menu3">menu 3</a></li> </ul> <div class="tab-content"> <div id="home" class="tab-pane fade in active"> <h3>home</h3> <p>lorem ipsum dolor sit amet, consectetur adipisicing elit, sed eiusmod tempor incididunt ut labore et dolore magna aliqua.</p> </div> <div id="menu1" class="tab-pane fade"> <h3>menu 1</h3> <p>ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p> </div> <div id="menu2" class="tab-pane fade"> <h3>menu 2</h3> <p>sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam.</p> </div> <div id="menu3" class="tab-pane fade"> <h3>menu 3</h3> <p>eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.</p> </div> </div>
the associated directive -
'use strict'; define(['app'], function (app) { var injectparams = ['showtab']; var wctabdirective = function (showtab) { return { link: function (scope, element, attrs) { element.click(function (e) { e.preventdefault(); $(element).tabs('show'); }); } } }; wctabdirective.$inject = injectparams; app.directive('wctab', wctabdirective); });
i have put break point in directive never reached.
you haven't applied "wc-tab" directive elements.
try adding directive tab anchor elements:
<a wc-tab showtab="" href="#menu1">menu 1</a>
check showtab
attribute correct well. if directive should applied show-tab=""
.
Comments
Post a Comment