Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ctrl click ng-click open page in new tab

Basically I want my app to open links in new tab/page when user holds down Ctrl (on linux windows), Cmd (on OSX). What is the way to go.

Note: I cannot get rid of ng-click. the application uses it various method calls within scope.

like image 215
Taranfx Avatar asked May 29 '14 07:05

Taranfx


1 Answers

Try this:

In HTML,

<div ng-click="gotoPageOrFunc($event)"></div>

In JS,

$scope.gotoPageOrFunc = function(event){
    if (event.ctrlKey==1){
        // Use windows.location or your link.
    }else{
        // Your actual functionalities.
    }
}
like image 74
Alagarasan M Avatar answered Oct 22 '22 20:10

Alagarasan M