A
A
Alex2016-05-20 17:07:49
Angular
Alex, 2016-05-20 17:07:49

How to interrupt a click on a link in Angular?

There is a link: It is
<a href="http://">Link</a>
necessary that when the link is clicked, a certain handler is executed. But the link didn't open. But at the same time, you need to keep the ability to navigate through it if the user opens the link in a new tab, or if he has disabled JS.
In jQuery it was done like this:

$('a').click(function() {
    // code
    return false;
});

But how to do this using angular?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
_
_ _, 2016-05-20
@AMar4enko

<a href="http://" ng-click="handleClick($event)"></a>

$scope.handleClick = function($event) {
  $event.preventDefault();
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question