I have controller 'reportCtrl'
and HTML that represents 6 tables with data and only several rows I show at once.
app.js
var appReport = angular.module('myAppReport', []); appReport.config(['$routeProvider', function($routeProvider) { $routeProvider.when('/showreport', {templateUrl: 'app/reports/reportsView.html', controller: 'reportCtrl'}); $routeProvider.when('/showreport/:type', {templateUrl: 'app/reports/reportsView.html', controller: 'reportCtrl'});
Each table has one button that on click, should open new tab in browser with extended table:
scope.onClick = function(path){ var real_path = $location.path() + '/' + path + '/'; $location.path( real_path ); // $window.open($location.path()); // doesn't work };
For example I have root view URL:
http://dev.test.com/reports/date/#/showreport
Now, after button is pressed I want to create :
http://dev.test.com/reports/date/#/showreport/table_name
and open it in new tab. As you see, I tried $window.open($location.path());
but it doesn't work, nothing happens.
Thanks,
You can make a HTML link open in a new tab by adding the target=”_blank” attribute. You should insert this after the link address.
You just need an anchor ( <a> ) element with three important attributes: The href attribute set to the URL of the page you want to link to. The target attribute set to _blank , which tells the browser to open the link in a new tab/window, depending on the browser's settings.
Use Keyboard with Mouse/Trackpad You can load any link in a new browser tab by clicking or tapping on it while holding down the Control key (Windows) or the Command key (Mac). Each tab loads in the background, so it's an ideal method to open multiple links as you move your way through a webpage.
You are opening a new window using another function which could get Angular confused.
Try passing the string in the $window.open(real_path)
where real_path is a string containing the path you want to navigate
If you want to open angular page in a new tab on ctrl+click or in same tab, then try this :-
HTML :
<a ng-click="navigationUrl($event)">My Link</a>
JS:
var navigationUrl = function (event) { if (event.ctrlKey) { window.open(url, '_blank'); // in new tab } else { $location.path(url); // in same tab } };
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