<div ng-controller="MyController"> <button ng-click="Plus()"></button> <h1>Hello {{ text }}</h1> <button ng-click="Reduction()"></button></div>
<script> angular.module(‘myApp‘,[]) .controller("MyController",function($scope){ $scope.text = 1 ; $scope.add = function(){ $scope.text += 1; }; $scope.subtract = function(){ $scope.text -= 1; } })</script>
时间: 2024-10-15 13:23:50