AngularJs open link in new tab – AngularJs new tab link

AngularJs open link in new tab – AngularJs new tab link

AngularJs open link in new tab – you’ll use $window service to open a link in new tab in angularjs. it’s terribly simple to open link in new tab mistreatment AngularJs. Here during this tutorial we tend to area unit progressing to make a case for however you’ll use the $window service to open link in new tab. you’ll additionally use our on-line editor to edit and run the instance code.

Angular open link in new tab with example and demo

You can open a link in new tab using the given following steps-

JavaScript Part –

JavaScript Part Contains the following script –

AngularJs open link in new tab Example For Angular open link in new tab::

<script>
var myNewTabApp = angular.module("myNewTabApp", []);
	myNewTabApp.controller("myNewTabController", function($scope,$window) {
		$scope.openNewLink = function() {
		$window.open('http://www.onlinecode', '_blank');
	};
});
</script>

Html Part –

This Contains the html part of the example For Angular open link in new tab::

Angularjs open link in new tab with Example:

<div ng-app="myNewTabApp">  
	<div ng-controller="myNewTabController">  
	<input type="button" class="btnset" value="Open In New tab " ng-click="openNewLink()"> 
</div>

Complete Part – Html & JavaScript Both

Let us combine the javascript and html both part to create the complete example –

AngularJs open link in new tab Example For AngularJs open link in new tab::

<!DOCTYPE html>
<html lang="en">
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"></script>
<script>
var myNewTabApp = angular.module("myNewTabApp", []);
	myNewTabApp.controller("myNewTabController", function($scope,$window) {
		$scope.openNewLink = function() {
		$window.open('http://www.onlinecode', '_blank');
	};
});
</script>
</head>
<body>  
<div ng-app="myNewTabApp">  
	<div ng-controller="myNewTabController">  
	<input type="button" value="Open In A New tab " ng-click="openNewLink()"> 
</div> 
</body>  
</html>

You also like AngularJs Pass Data to $http.get request AND AngularJs Call Function on Page Load with example

Leave a Comment

Your email address will not be published. Required fields are marked *

  +  78  =  88

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US