angular-owl-carousel icon indicating copy to clipboard operation
angular-owl-carousel copied to clipboard

Add callbacks

Open elvisss opened this issue 10 years ago • 2 comments

Hi, I need add Custom Events, how it could be implemented? Thanks.

elvisss avatar May 13 '15 22:05 elvisss

@ElvisSaavedra I'm not sure, I haven't looked at the code in a while. But you can call directive attributes as functions when events in Owl are triggered. For example:

return {
    link: function (scope, attributes, element) {
        // trigger function in attribute
        scope.myFunc();
    }
};

<angular-owl-carousel my-func="ctrl.doSomething()"></angular-owl-carousel>

Of course this will all require changes to the directive.

jonahbron avatar May 21 '15 17:05 jonahbron

a work around i found for now is to add the event you want during the parsing of options. callback being the function called when that event is fired.

                for (var i = 0; i < owlOptions.length; i++) {
                    var opt = owlOptions[i];
                    if (attributes[opt] !== undefined) {
                        options[opt] = $parse(attributes[opt])();
                    } else if (opt === 'onChange') {
                        options[opt] = callback;
                    }
                }

rsquared86 avatar Dec 10 '15 01:12 rsquared86