Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
529 views
in Technique[技术] by (71.8m points)

angularjs - Ctrl单击ng单击新选项卡中的打开页面(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).

(基本上,我希望我的应用程序在用户按住Ctrl键(在Linux Windows上),Cmd键(在OSX上)时在新选项卡/页面中打开链接。)

What is the way to go.

(怎么走。)

Note: I cannot get rid of ng-click.

(注意:我无法摆脱ng-click。)

the application uses it various method calls within scope.

(应用程序在范围内使用它的各种方法调用。)

  ask by Taranfx translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try this:

(尝试这个:)

In HTML,

(在HTML中,)

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

In JS,

(在JS中)

$scope.gotoPageOrFunc = function(event){
    if (event.ctrlKey==1){
        // Use windows.location or your link.
    }else{
        // Your actual functionalities.
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...