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

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -