Ng-Click-2

 

In this example ng-click directive call the showAlert() function which will show the alert "This is an example of ng-click".

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Welcome to LearnKode - A code learning platform</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> </head> <body ng-app="clickExample"> <div ng-controller="ExampleController"> <a href="javascript:void(0)" ng-click="showAlert()">Click Here </a> </div> <script> var app = angular.module("clickExample", []); app.controller('ExampleController', ['$scope', function ($scope) { $scope.showAlert = function () { alert("This is an example of ng-click"); } }]); </script> </body> </html>
Output