简体   繁体   English

在新标签页/窗口中打开新视图

[英]Open new view in new tab/window

I'm trying to handle the 'wheel click' and 'right-click > open in new tab/window' in order to load the targeted view in the new tab/window. 我正在尝试处理“滚轮单击”和“右键单击>在新标签页/窗口中打开”,以便将目标视图加载到新标签页/窗口中。

Let's say in one of my view, I have something like this : 让我们说一种观点,我有这样的事情:

  <li><a href="javascript:void(0)" ng-click="h.changeView('projects')">Time Tracking</a></li>
  <li><a href="javascript:void(0)" ng-click="h.changeView('requests')">Dashboard</a></li>

The changeView() function in my controller looks like this : 我的控制器中的changeView()函数如下所示:

  this.changeView = function(viewPath) {
    $location.path(viewPath);
  };

And the route configuration like this : 和这样的路由配置:

// Routes configuration
app.config(['$routeProvider', function($routeProvider) {
  $routeProvider
    .when('/', {
      templateUrl: 'requests/requestsList.html',
      controller: 'requestsController',
      controllerAs: 'r'
    })
    .when('/requests', {
      templateUrl: 'requests/requestsList.html',
      controller: 'requestsController',
      controllerAs: 'r'
    })
    .when('/projects', {
      templateUrl: 'projects/projectsList.html',
      controller: 'projectsController',
      controllerAs: 'p'
    })
    .otherwise({
      redirectTo: '/'
    });
}]);

How could I handle the displaying of a new view in a different tab/window ? 如何处理在其他标签/窗口中显示的新视图?

Also, is there a syntax in my $routeProvider that allows me to combine the / and /requests in the same when(...) ? 另外,我的$routeProvider中是否有语法允许我在相同的when(...)组合//requests

Simple HTMl will help you there. 简单的HTMl将为您提供帮助。 Add in your HTML code a target="_blank" 在您的HTML代码中添加target =“ _ blank”

Try using $window service: 尝试使用$ window服务:

this.changeView = function(viewPath) {
  $window.open(viewPath, '_blank');
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM