javascript - AngularJs - Open url in new tab -
i have application public page , admin page. open admin page in new tab after login. i've tried this, after login successful, no effect. public page (where login is) being reloaded:
var url = $state.href('/admin/overview'); $window.open(url, '_blank');
any tips appreciated. thank you.
here working jsfiddle, have inject $window
before 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>
Comments
Post a Comment