title: How to prevent redirecting <a href="#something"> in Angular Js1.2
body: <p>I was using AngularJs-1.0.7 and Bootstrap in my application. Recently I migrated from AngularJs-1.0.7 to AngularJs-1.2. I am using Bootstrap's Accordions and Tabs.</p>
  
  <p>Html code for Tab contains <code>&lt;a href="#id_for_content"&gt;</code> as shown below.</p>
  
  <pre><code>&lt;ul id="myTab" class="nav nav-tabs"&gt;
      &lt;li class="active"&gt;&lt;a href="#firstTab" data-toggle="tab"&gt;Home&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="#secondTab" data-toggle="tab"&gt;Profile&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  
  &lt;div id="myTabContent" class="tab-content"&gt;
      &lt;div class="tab-pane fade in active" id="firstTab"&gt;
        &lt;p&gt;Content for first tab.&lt;/p&gt;
      &lt;/div&gt;
      &lt;div class="tab-pane fade" id="secondTab"&gt;
        &lt;p&gt;Content For second tab.&lt;/p&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>In Angular's old versions, route change happens only if we give anchor tag like <code>&lt;a href="#/firstTab"&gt;</code>. But AngularJs-1.2 redirects <code>&lt;a href="#firstTab"&gt;</code>. It doesn't consider the <code>/</code> in between <code>#</code> and <code>firstTab</code>. Hence while clicking on Tab it redirects to <code>http://web_url/#/firstTab</code> . How to solve this issue?</p>
  
  <hr/>
  
  <h3>My Solution</h3>
  
  <p>I found a solution for this issue. I wrote a directive for a tag. In that directive I checked for href attribute. If it matches prevent from its default behavior. Check the following code.</p>
  
  <pre><code>app.directive('a', function() {
      return {
          restrict: 'E',
          link: function(scope, elem, attrs) {
              if(attrs.href === '#firstTab'|| attrs.href === '#secondTab'){
                  elem.on('click', function(e){
                      e.preventDefault();
                  });
              }
          }
     };
  }); 
  </code></pre>
  
  <p>But the problem with this method is, I have to check each and every tab ids or accordion ids here. If I use dynamic Ids for them, its not possible to check in directive. </p>
  
  <p>If you can find better solution, let us all know about it.</p>