AngularJs - Open url in new tab(AngularJs - 在新标签页中打开网址)
问题描述
我有一个带有公共页面和管理页面的应用程序.我想在登录后在新选项卡中打开管理页面.我试过这个,登录成功后,但没有效果.公共页面(登录所在的位置)正在重新加载:
I have an application with a public page and an admin page. I would like open the admin page in a new tab after login. I've tried this, after the login was successful, but to no effect. The public page (where the login is) is just being reloaded:
var url = $state.href('/admin/overview');
$window.open(url, '_blank');
任何提示将不胜感激.谢谢.
Any tips would be appreciated. Thank you.
推荐答案
这是一个工作 JSFiddle,你必须先注入 $window 才能使用它:
Here is a working JSFiddle, you have to inject $window before you can use it:
JS:
angular.module('myApp', [])
    .controller('dummy', ['$scope', '$window', function ($scope, $window) {
    $scope.redirectToGoogle = function () {
        $window.open('https://www.google.com', '_blank');
    };
}]);
HTML:
<div ng-app="myApp" ng-controller="dummy"> 
    <a ng-href="" ng-click="redirectToGoogle()">Hello</a>
</div>
这篇关于AngularJs - 在新标签页中打开网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:AngularJs - 在新标签页中打开网址
 
				
         
 
            
        基础教程推荐
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
 
    	 
    	 
    	 
    	 
    	 
    	 
    	 
    	 
						 
						 
						 
						 
						 
				 
				 
				 
				