Search code examples
javascripthtmlangularjstwitter-bootstrapangularjs-routing

Bootstrap tabs aren't working with AngularJS routes. 'data-target' isn't working too


I got this code from the Bootswatch website, it supposed to work just fine :

<ul class="nav nav-tabs">
  <li class="active"><a href="#home" data-toggle="tab" aria-expanded="true">Home</a></li>
  <li class=""><a href="#profile" data-toggle="tab" aria-expanded="false">Profile</a></li>
  <li class=""><a href="#other" data-toggle="tab" aria-expanded="false">Other</a></li>
</ul>
<div id="myTabContent" class="tab-content">
  <div class="tab-pane fade active in" id="home">
    <p>Tab home!</p>
  </div>
  <div class="tab-pane fade" id="profile">
    <p>Tab Profile!</p>
  </div>
   <div class="tab-pane fade" id="other">
    <p>Tab Other!</p>
  </div>
</div>

But I'm using AngularJS routes, so the href links aren't working, I tried to replace href with data-target, but it doesn't work either. Please help, and is there a simple way to change the Tab class to active while active? Thank you.


Solution

  • You'll want to look into using Angular-UI for Bootstrap components like this. It gives you Bootstrap components like tabs that have been written specifically for AngularJS applications. Check out the "Tabs" section on that link.