Ng-Focus-1

 

In this example of Ng-Focus, Anchor will redirect user to learnkode.com using the function below: $scope.url = function () { window.location = 'http://learnkode.com'; } HTML: LearnKode URL:LearnKode

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> </head> <body ng-app="myApp"> <div ng-controller="LearnItController"> <div class="container"> LearnKode URL:<a href="javascript:void(0)" ng-focus="url()"><b>LearnKode</b></a> </div> </div> <script> var app = angular.module("myApp", []); app.controller('LearnItController', ['$scope', function ($scope) { $scope.url = function () { window.location = 'http://learnkode.com'; } }]); </script> </body> </html>
Output