0

I am using the angular-bootstrap's (ui.bootstrap) uib-carousel component with custom template to change the style, text, and functionality of the back and next buttons. I have to perform other actions when the "next" button is touched, in addition to the component's original functionality. Following the method of "capturing" the select event in this answer: How do you Bind to Angular-UI's Carousel Slide Events?, I modified the answer to use the next event.

the html declaration

<uib-carousel template-url="/tpl.html" active="vm.wizardStep" no-wrap="true" on-carousel-next="vm.onNext()" style="height: 395px;">

and the directive like so

.directive('onCarouselNext', function($parse) {
  return {
    require: '^uibCarousel',
    link: function(scope, element, attrs, carouselCtrl) {
      var callBack = $parse(attrs.onCarouselNext);
      var origNext = carouselCtrl.next;
      carouselCtrl.next = function() {
        callBack(scope);
        return origNext.apply(this, arguments);
      };
    }
  };
});

The uib-carousel's next event does get fired, but it is not calling it through my directive. Just to compare apples to apples, I tried using the code in the answer as-is (i.e. capturing the "select" event), and that does work perfectly and calls my callback function. The reason I need to capture the "next" and can't use the "select" is because I'm using this to set up a "wizard" type framework, and the final "next" is a "done" that needs to do different code.

Anyone done something like this and get it to work?

Community
  • 1
  • 1
Shaggy13spe
  • 733
  • 10
  • 22

1 Answers1

0

So seeing as how I was trying to "hijack" the carousel control to turn it in to a wizard control, I ended up just taking the carousel code and changing it completely to fit my needs. If anyone would like to see the code, let me know and I'll put it out on github.

Shaggy13spe
  • 733
  • 10
  • 22
  • @AnishV, what I have now is pretty customized for the project I'm on. I intend to however try and clean it up so that it is less geared for my exact form factor specifications and then put it out on Github. Will let you know when I do. – Shaggy13spe Oct 17 '16 at 17:08
  • 1
    @AnishV I haven't had time to totally "sanitize" my code, but here's the controller code for the directives. You should be able to create templates that are more custom to what you need than mine (though I'll be adding mine once I have it more "general"). https://github.com/Shaggy13spe/ngWizard – Shaggy13spe Oct 25 '16 at 02:44