Open link in AngularJS $state in new tab with ctrl + click


utkash sharma

I'm trying to open a link in a new tab, just like when opening a normal link ctrl + clicked, except it appends a ui-sref directive that generates a ui-sref directive with an href attribute /stateName?param1=test&param2=test, since the tab is opened using the URL:open of domain.com/stateName?param1=test&param2=test.

The problem now is that my app loads in

URL-domain.com/SomePath#/

and the generated link (ui-sref) is

URL-domain.com/StateName?param1=test&param2=test

Is there any way to provide base URL to ui-srefwhen ctrl + clicked. I also want to keep its normal behavior when clicking without Ctrl?

Forest

如果您创建自己的函数来处理此行为,则此方法应该起作用。这是在编辑模式/小提琴预览模式下工作的小提琴此解决方案确实提供了逻辑。请自行创建所需的网址。请注意,小提琴正在阻塞popups

视图

<a ng-click="specialClick($event, 'stateName', { param: 'value'})">Click me</a>

AngularJS控制器

$scope.specialClick = function (e, state, params) {
   if (e.ctrlKey) {
      window.open($state.href(state, params, '_blank'));
   } else {
      $state.go(state, params, {notify: false});
   }
}

Related


Open link in AngularJS $state in new tab with ctrl + click

utkash sharma I'm trying to open a link in a new tab, just like when opening a normal link ctrl + clicked, except it appends a ui-sref directive which generates a ui-sref directive with an href attribute /stateName?param1=test&param2=test, since the tab is ope

Open link in AngularJS $state in new tab with ctrl + click

utkash sharma I'm trying to open a link in a new tab, just like when opening a normal link ctrl + clicked, except it appends a ui-sref directive that generates a ui-sref directive with an href attribute /stateName?param1=test&param2=test, since the tab is open

Open link in AngularJS $state in new tab with ctrl + click

utkash sharma I'm trying to open a link in a new tab, just like when opening a normal link ctrl + clicked, except it appends a ui-sref directive that generates a ui-sref directive with an href attribute /stateName?param1=test&param2=test, since the tab is open

Open link in AngularJS $state in new tab with ctrl + click

utkash sharma I'm trying to open a link in a new tab, just like when opening a normal link ctrl + clicked, except it appends a ui-sref directive that generates a ui-sref directive with an href attribute /stateName?param1=test&param2=test, since the tab is open

Open link in AngularJS $state new tab

Alex Arvanitidis : I'm trying to implement the "open link in new tab" functionality using the $state.go function. It would be great if there was something like this: $state.go('routeHere', { parameter1 : "parameter" }, { reload : true, newtab :

Open link in AngularJS $state new tab

Alex Arvanitidis : I'm trying to implement the "open link in new tab" functionality using the $state.go function. It would be great if there was something like this: $state.go('routeHere', { parameter1 : "parameter" }, { reload : true, newtab :

Open link in AngularJS $state new tab

Alex Arvanitidis : I'm trying to implement the "open link in new tab" functionality using the $state.go function. It would be great if there was something like this: $state.go('routeHere', { parameter1 : "parameter" }, { reload : true, newtab :

Selenium - click on the link to open a new tab

tree 55 I've seen a lot of threads on how to open a link in a new tab, but what if you have a link that creates a new tab and you need to verify the title? All I need to do is click the link -> confirm the new tab has the correct title -> close the tab and con

Selenium - click on the link to open a new tab

tree 55 I've seen a lot of threads on how to open a link in a new tab, but what if you have a link that creates a new tab and you need to verify the title? All I need to do is click the link -> confirm the new tab has the correct title -> close the tab and con

Selenium - click on the link to open a new tab

tree 55 I've seen a lot of threads on how to open a link in a new tab, but what if you have a link that creates a new tab and you need to verify the title? All I need to do is click the link -> confirm the new tab has the correct title -> close the tab and con

Right click and save link to open in new tab

Dishu I added a custom right click menu using jquery in my project, now what I want to achieve is: -> If anyone right clicks on the link, the option will say "Open link in new tab", when that option is selected, it will open in a new tab with that link. -> Oth

Bind click event to open link in new tab

123 I'm trying to open all links in a modal in a new tab, manipulating the DOM is not as easy as I thought due to the limitations of using angular. Is there a way to bind a click event to a link and then make the click event open a new tab? I have something li

Selenium - click on the link to open a new tab

tree 55 I've seen a lot of threads on how to open a link in a new tab, but what if you have a link that creates a new tab and need to validate the title? All I need to do is click the link -> confirm the new tab has the correct title -> close the tab and conti

Open a new tab after button click in AngularJS

Neptune: <button type="button" class="btn btn-primary" ng-click="openTab()">new tab</button> openTab = function () { $http.post('www.google.com'); } What I want is to post a requirement and then open the response html in a new tab when the "openTab" button

Open a new tab after button click in AngularJS

Neptune: <button type="button" class="btn btn-primary" ng-click="openTab()">new tab</button> openTab = function () { $http.post('www.google.com'); } What I want is to post a requirement and then open the response html in a new tab when the "openTab" button

Open a new tab after button click in AngularJS

Neptune: <button type="button" class="btn btn-primary" ng-click="openTab()">new tab</button> openTab = function () { $http.post('www.google.com'); } What I want is to post a requirement and then open the response html in a new tab when the "openTab" button

AngularJS - use click to open link in new window

kenshin9 First, I'm not sure if the title I came up with accurately describes what I'm trying to do. I have a table of tasks and each task has an assignment action. Basically, under normal circumstances, the user would click on a link where a call would be mad

jQuery/JavaScript - Allow CTRL+click to open links in new tab

Nsilva Is there a way in jQuery or JavaScript to enable the user to CTRL+click a link to open the link in a new tab (like <a href="">example</a>element) ? Here is an example of what I'm talking about:- jQuery('#some-link').bind('click', function() { window.

jQuery/JavaScript - Allow CTRL+click to open links in new tab

Nsilva Is there a way in jQuery or JavaScript to enable the user to CTRL+click a link to open the link in a new tab (like <a href="">example</a>element) ? Here is an example of what I'm talking about:- jQuery('#some-link').bind('click', function() { window.

jQuery/JavaScript - Allow CTRL+click to open links in new tab

Nsilva Is there a way in jQuery or JavaScript to enable the user to CTRL+click a link to open the link in a new tab (like <a href="">example</a>element) ? Here is an example of what I'm talking about:- jQuery('#some-link').bind('click', function() { window.

jQuery/JavaScript - Allow CTRL+click to open links in new tab

Nsilva Is there a way in jQuery or JavaScript to enable the user to CTRL+click a link to open the link in a new tab (like <a href="">example</a>element) ? Here is an example of what I'm talking about:- jQuery('#some-link').bind('click', function() { window.

"Open in new tab" click link does not open href value

99 encoder I am using Vue2 and I have and <a>markup . This works as expected with a left click (it's calling a method), but if I do a , which is the open value in this case, it 's wrong.href='#'@click.prevent="someMethod()" right click -> open in new tabhref W

Click the link to open the tab

Shakamar I want to open a tab when a user clicks an image link on the following website : http://m.theseolounge.co.uk/index.php/jadever-jad-jce-counting-scale.html The code for the tab is as follows: <ul class="tabs clearer"> <li id="tab-additional"><a href=

Open link in new tab

no mice here I need to open a link <a>in a new tab/window 's tab, do something there and then close it. html code: <body> <a id="uniqueid" href="somelink">I need to open this in a new tab</a> </body> python code: from selenium import webdriver driver = w

Window cannot open new window or tab on external URL link click

Rajish Kapoor I need to open a URL using pyQt5. The page has several links that open new windows. pyQt5 opens a window for the URL, but after clicking the link that should open a new window, nothing happens. PS I am using pyQt5.6 I've tried it on Linux centOs,

Window cannot open new window or tab on external URL link click

Rajish Kapoor I need to open a URL using pyQt5. The page has several links that open new windows. pyQt5 opens a window for the URL, but after clicking the link that should open a new window, nothing happens. PS I am using pyQt5.6 I've tried it on Linux centOs,

Left click on link doesn't work, but "open in new tab" works

rock degree I'm working on my personal website (built from a template) and when I'm done, my links stop responding to left clicks. They work fine if you right click and select "Open in New Tab". You can see the URL in the status bar at the bottom of the browse