AngularJS onclick call function

AngularJS onclick call function

If you are trying to call function on button click using AngularJs please use below code:

<!DOCTYPE html>
<meta charset="ISO-8859-1">
<title>AngularJS on click function call</title>
<script src=""></script>

	var app = angular.module('myApp', []);
	app.controller('controller', ['$scope', function($scope) {
	    $scope.function1 = function(msg) {
	         alert(msg + ' first function call!');   
	    $scope.function2 = function(msg) {
	         alert(msg + ' second function call!');   
	<div data-ng-app="myApp">
		<div data-ng-controller="controller">
			<button data-ng-click="function1('AngularJS')">Call first function</button>
			<button data-ng-click="function2('AngularJS')">Call second function</button>



AngularJS onclick call function


4 thoughts on “AngularJS onclick call function

Leave a Reply

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

I am not Robot *