ng-click

ng-click用来指定一个元素被点击时调用的方法或表达式。

<div ng-controller="CounterController">
    <button ng-click="count = count + 1"
            ng-init="count=0">
        Increment
    </button>
    count: {{ count }}

<button ng-click="decrement()">

 Decrement
    </button>

<div>

angular.module('myApp',[])
.controller('CounterController', function($scope) {
    $scope.decrement = function() {
        $scope.count = $scope.count - 1;

};}) 


你可能感兴趣的:(AngularJS)