I have a table on HTML and each row leads to a different page, with more details about that row. But as I am using angularjs, with ng-click I can't right click this row and select 'open in a new tab'. Is there any way to solve it?
Thanks in advance!
To open the link in a new tab, we can use the <a> element by passing a target attribute with a value _blank . Note: In the example above, we have used the href attribute to pass a link instead of routerLink because the routerLink attribute appends the URL to the current URL path.
A simple method to open link in new tab, <a href="{{details. website}}" ng-click="openNewTab(details. website)"> {{details.
For a single btn, it's ok to use ng-click or onclick in the ng-app . There is no difference between the two functions. For effective team work, you,d better to have an account with each other. In Angular apps, ng-click is recommended.
We can add ng-click event conditionally without using disabled class.
If possible you should convert your element to an anchor element.
<a ng-href="{{ your dynamic url }}" ng-click="your function">Your link text</a>
The browser will interpret the element as a link, and will therefor give you the correct dropdown. Note that you also have to have the correct href value to open in a new tab.
EDIT: I would recommend this question if you want a more detailed answer on how to fix this kind of behaviour using JQuery.
Inside your ng-click function you can call window.open(url, '_blank')
however as a word of warning, this will depend on the browser and current settings.
In some cases this will open in a pop-out window and in other cases it will open in a new tab. There is no way to force either behavior as the javascript is browser agnostic, it has simply requested a new window and it is up to the browser the decide how to implement it. see here for a discussion on forcing a tab or window
However the only way to get that right-click option or the ctrl+click to open in a new tab is if the browser sees a <a>
tag. Otherwise it doesn't treat it as a link.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With