angular-owl-carousel
angular-owl-carousel copied to clipboard
Add callbacks
Hi, I need add Custom Events, how it could be implemented? Thanks.
@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.
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;
}
}