Skip to content
This repository has been archived by the owner on Apr 13, 2024. It is now read-only.

Add callbacks #4

Open
elvisss opened this issue May 13, 2015 · 2 comments
Open

Add callbacks #4

elvisss opened this issue May 13, 2015 · 2 comments

Comments

@elvisss
Copy link

elvisss commented May 13, 2015

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

@jonahbron
Copy link
Owner

@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.

@rsquared86
Copy link

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;
                    }
                }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants