How to open new tab in browser by using $location, angular?

Viewed 68642

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,

8 Answers

try this

window.open(yourURL+'create-account',)

window.open by default open link in new tab

Related