As in the title writes, is it possible to intercept tab change event and execute some function before that occurs?
1 Answer
Yes you can, just add an ng-click on the uib-tab directive
Here's a demo plunker (note how the code runs before the view changes).
4 Comments
softzer0
I have thought of that solution but haven't dared to try, thanks! I was thinking whether is there some better way instead of putting
ng-click directive on the every tab? I think that this wouldn't be possible to do if I'm adding new tabs later i.e. dynamically?svarog
if you'll add them dynamically, you'll probably use something like
ng-repeat, and that will just recopy the same template with the ng-click, if you'll want something more "robust" you can use promises (i.e. cancel event if the promise rejects..)softzer0
I have one more question: Why do I have to include
$event in the function if it's not used?svarog
you don't really need, i've added it but didn't used it, basically it's the event object, you can modify, and event cancel it