Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49167

What's the correct method to bind to on-tap event on a custom directive?

$
0
0

@wggley wrote:

I tried to bind this way:

(function() {
    angular
        .module('mymodule')
        .directive('mydirective', mydirective);

    mydirective.$inject = [];

    function mydirective() {
        return {
            link: function(scope, element, attrs) {
                element.on('tap', function() {
                    //do something
                });
            }
        }
    }
})();

But don't worked, if I try to bind a click event it works nicely.

This was the only method I could bind (I looked at ionic.bundle.js to see how you bind):

(function(ionic) {
    angular
        .module('mymodule')
        .directive('mydirective', mydirective);

    mydirective.$inject = [];

    function mydirective() {
        return {
            link: function(scope, element, attrs) {
                ionic.on('tap', function() {
                    //do something
                }, element[0]);
            }
        }
    }
})(ionic);

What I'm missing here?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49167

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>