AngularJS事件
<body ng-app="myApp"> <div ng-controller="myCtrl"> <button ng-click="jisuan()">点击</button> <h1>{{result1}}</h1> <button ng-click="result2=result2+1">点击</button> <h1>{{result2}}</h1> <button ng-click="toggle()">点击</button> <h1 ng-show="bool">{{result3}}</h1> </div> <script> var app = angular.module('myApp', []); app.controller("myCtrl", ["$scope", function (scope) { scope.result1 = 0; scope.result2 = 0; scope.result3 = '看不见我'; scope.bool = true; scope.jisuan = function () { scope.result1 += 1; } scope.toggle = function () { scope.bool = !scope.bool; } }]); </script> </body>