Cami Rodriguez Cami Rodriguez - 1 year ago 131
AngularJS Question

How to catch event onclick without ng-click Angular.js

I'm developing an Angular App but I want to catch onclick event without ng-click, I want to use something like that


Answer Source

AngularJs use directive to operate dom. you can add a directive like this.


YourApp.directive('testClick', function () {
    return {
        restrict: 'A',
        link: function (scope, element) {
            element.onclick = function() {
                //do some thing.


<button test-click>Test Click</button>