简体   繁体   English

使用Angularjs在按钮单击的另一个选项卡上打开html

[英]Open html on another tab on button click using Angularjs

I have a page in my AngularJS that has an edit button, I need to open the edit page on another tab when I click the edit button. 我的AngularJS中有一个带有编辑按钮的页面,单击编辑按钮时,需要在另一个选项卡上打开编辑页面。 Can it be possible using the angular way? 可以使用角度方式吗? I need to use the same controller to be able to access the data. 我需要使用相同的控制器才能访问数据。 How can I possible do this? 我该怎么办? Can someone please give me a sample? 有人可以给我样品吗?

Here's a fiddle to show opening the tab: 这是显示打开选项卡的小提琴:

https://jsfiddle.net/e8g1m0xs/ https://jsfiddle.net/e8g1m0xs/

Ie: 即:

angular.module('new_tab', [])
  .controller('ExampleController', ['$scope', '$window', function($scope, $window) {
    $scope.openTab = function() {
      $window.open('https://www.google.com', '_blank');
    };
  }]);

<div ng-app="new_tab" ng-controller="ExampleController">
  <button ng-click="openTab()">New Tab</button>
</div>

But in order to use the same controller for the new tab, and do something like pass information to it, you would have to implement a wildcard pattern into your angular router to pass along state information. 但是,为了对新选项卡使用相同的控制器,并像向其传递信息一样,您必须在角度路由器中实现通配符模式以传递状态信息。 I usually do things like that using UI Router. 我通常使用UI Router做类似的事情。 See the section titled URL Parameters . 请参阅标题为“ URL参数”的部分。

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

相关问题 在 AngularJS 中单击按钮打开一个新选项卡 - Open a new tab on button click in AngularJS 使用angularjs选项卡时如何在单击按钮时移动到下一个选项卡 - How to move to next tab on click of a button when using angularjs tab 如何在单击按钮时显示html内容,而不是使用angularjs创建新的标签(如向导)? - How to display html content on button click instead of creating new tab like wizard using angularjs? 单击页面上的另一个按钮时如何打开导航/选项卡? - How to open the nav/tab when I click another button on the page? 使用ctrl + click在新选项卡中打开AngularJS $状态链接 - AngularJS $state open link in new tab using ctrl + click 使用Chrome Tabs API单击按钮打开标签页 - Open tab with button click using Chrome Tabs API 如何使用 Playwright 打开新选项卡(例如单击按钮在新选项卡中打开新部分) - How to open the new tab using Playwright (ex. click the button to open the new section in a new tab) 我可以使用AngularJS在html中单击链接时打开CSV文件吗? - Can i open a CSV file on click of a link in html using AngularJS? 如果使用引导程序,如何在单击按钮时将一个选项卡切换到另一个选项卡? - How to switch one tab to another on button click if using bootstrap? 如何更改angularjs中按钮单击的活动选项卡? - How to change active tab on button click in angularjs?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM