如何通过使用$ location,angular在浏览器中打开新标签页? [英] How to open new tab in browser by using $location, angular?
问题描述
我有控制器'reportCtrl'
和HTML,它们代表6个带有数据的表,并且一次只能显示几行.
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
};
例如,我有根视图URL:
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
并在新标签页中将其打开.如您所见,我尝试了$window.open($location.path());
,但是它不起作用,什么也没发生.
and open it in new tab. As you see, I tried $window.open($location.path());
but it doesn't work, nothing happens.
谢谢
推荐答案
您正在使用另一个函数打开新窗口,这可能会使Angular感到困惑.
You are opening a new window using another function which could get Angular confused.
尝试在$window.open(real_path)
中传递字符串,其中real_path是包含要导航路径的字符串
Try passing the string in the $window.open(real_path)
where real_path is a string containing the path you want to navigate
这篇关于如何通过使用$ location,angular在浏览器中打开新标签页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!