JSFiddle - React, Tailwind, and code Playground

by vrpruthvi

HTML

<div ng-app="MyApp" ng-controller="TestController">
  <a href="" ng-click="myFunction();">Click here</a> to open random links in a new tab!
</div>

JavaScript

// App declaration
var MyApp = angular.module("MyApp", []);
// App controller
MyApp.controller("TestController", ["$scope", "$window", function($scope, $window) {
	var sampleLinks = [
  	"http://www.google.com",
    "http://www.facebook.com",
    "http://www.twitter.com",
    "http://www.instagram.com",
    "http://www.gmail.com"
  ]
  $scope.myFunction = function() {
  	var randomIndex = Math.floor(Math.random()*sampleLinks.length);
    $window.open(sampleLinks[randomIndex], '_blank');
  };
}]);