AngularJS ng-click
Yönergesi
Örnek
Düğmeye her tıklandığında sayı değişkenini bir artırın:
<button ng-click="count = count + 1" ng-init="count=0">OK</button>
Tanım ve Kullanım
Yönerge ng-click
, AngularJS'ye bir HTML öğesine tıklandığında ne yapacağını söyler.
Sözdizimi
<element ng-click="expression"></element>
Tüm HTML öğeleri tarafından desteklenir.
Parametre Değerleri
Value | Description |
---|---|
expression | An expression to execute when an element is clicked. |
Daha fazla örnek
Örnek
Bir düğme tıklandığında AngularJS'de bir işlev yürütün:
<body ng-app="myApp">
<div ng-controller="myCtrl">
<button ng-click="myFunc()">OK</button>
<p>The button has been clicked {{count}} times.</p>
</div>
<script>
angular.module('myApp', [])
.controller('myCtrl', ['$scope',
function($scope) {
$scope.count = 0;
$scope.myFunc = function() {
$scope.count++;
};
}]);
</script>
</body>