[英]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.