这是我的aspx:
<body ng-controller="myController">
<form id="form1" runat="server">
<div>
<input type="button" value="Press" ng-click="incrementCount()" ng-init="count=0"/>
<span>{{ count }}</span>
</div>
</form>
</body>
以下是JS:
angular.module('myModule', [])
.controller('myController', function ($scope, $http) {
$scope.incrementCount = function () {
$scope.count = $scope.count + 2;
};
});
我的代码有什么问题? 当我点击“按下”按钮时,它不能正常工作。
答案 0 :(得分:0)
angular.module('myModule', []) .controller('myController', function ($scope, $http) {
$scope.incrementCount = function () {
$scope.count = $scope.count + 2;
};
});
&#13;
<!DOCTYPE html>
<html lang="en-US">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body ng-app="myModule" ng-controller="myController">
<form id="form1" runat="server">
<div>
<input type="button" value="Press" ng-click="incrementCount()" ng-init="count=0"/>
<span>{{ count }}</span>
</div>
</form>
</body>
</html>
&#13;
它正常工作!单击“运行”。