Arpit Shah
Arpit Shah

Reputation: 47

How to call the angular function on ng-click of a href

a href tag

<a href="#" ng-click="getUserSkills($event);" data-id="{{iUserInfoID}}" class="accordion-toggle" title="Skills" data-toggle="modal" data-target="#skillModal">Skills</a>

Angular Controller

    $scope.getUserSkills=  function (e) {
    e.preventDefault();
    $scope.UserInfoId = $(this).data('id');
    alert($scope.UserInfoId)

};

Upvotes: 0

Views: 766

Answers (1)

Vladimir Zdenek
Vladimir Zdenek

Reputation: 2290

You can just remove the href="#" from the link.

<a ng-click="getUserSkills($event);">My Link</a>

But I would suggest you use just a span or something similar instead. There is no reason why you should try to suppress a default functionality of a when you can use any other HTML tag.

Upvotes: 2

Related Questions