How to best way to use angular ng-click event

ng-click

The ngClick mandate permits you to indicate custom conduct when a component is clicked.

You can use function or any condition which you specified to execute on click event on specific element

Some Example

Create a new controller

<script>
 var myFirstApp = angular.module('myFirstApp', []);
 myFirstApp.controller('myCtrl', function($scope) {
  
  $scope.counterStart = 0;
  
 });
</script>

Now you can add html simple code to execute angular ng-click event

<span ng-app="myFirstApp" ng-controller="myCtrl">
 <button ng-click="counterStart = counterStart + 1"> Start counter!</button>
 <p>{{ counterStart }}</p>
</span>

Share this

Related Posts

First