user3106347
user3106347

Reputation: 658

call function when users click on "open link in new tab"

I am using Angularjs. In my application i have one link say(opentab).I have added ng-click event on this

<a href="javascript:void(0);" ng-click="clickevent()">opentab</a> 

I want when users right click on "opentab" and select "open link in new tab" it call clickevent function

Thanks

Upvotes: 0

Views: 1650

Answers (1)

Vaibhav Jain
Vaibhav Jain

Reputation: 727

You can not detect that, but you can detect the ctrl + click, cmd + click etc. something like this.

HTML

<div ng-app="myApp" ng-controller="mainController">
  <a href="javascript:void(0);" href="javascript:void(0);" ng-click="clickevent($event)">Opentab</a> 
</div>

JS

var app = angular.module("myApp", []);
  app.controller("mainController", function($scope) {
        $scope.clickevent = function($event){
          if (event.ctrlKey || event.shiftKey || event.metaKey || $event.which == 2) {
            alert("aa");
          }

        }
    });

Hope it help, Cheers :)

Upvotes: 1

Related Questions