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.
try data-target="#something"
, it works fine for me in both development and production environment.
Just add this to your links:
target="_self"
And you're ready ;)
I've been having this problem for a while now too, and I only just stumbled across this question (and your own answer). It turns out that you are almost correct with your solution, just a slight modification makes it work as you'd like.
In addition to the issue you were having with tabs, I was also encountering this problem with dropdown links -- they were navigating away from the current page when clicked, instead of dropping down the menu -- and in fact, this problem is present on any link that was designed to toggle something, i.e. with the data-toggle attribute set.
So, a slight modification to your code to check for the presence of the 'toggle' attribute solves it for me:
app.directive('a', function() {
return {
restrict: 'E',
link: function(scope, elem, attrs) {
if(attrs.toggle){
elem.on('click', function(e){
e.preventDefault();
});
}
}
};
});
Hope this helps!