Reputation: 11
Here it actually increments and once refreshed the values begin from 0.
<div ng-app="myApp" ng-controller="myCtrl">
<button ng-click=count=count+1>Download</button>
<p> {{ count }} </p>
</div>
<script>
var app=angular.module("myApp",[]);
app.controller("myCtrl",function($scope)
{
var count=0;
$scope=count;
})
</script>
</body>
</html>
I need to increment and update counter.
Thanks in advance.
Upvotes: 0
Views: 274
Reputation: 11
Your code has lot of typo error. Please use the below code to achieve your output
<div ng-app="myApp" ng-controller="myCtrl">
<button ng-click="increment()">Download</button>
<p> {{ count }} </p>
</div>
<script>
var app=angular.module("myApp",[]);
app.controller("myCtrl",function($scope){
$scope.count = 0;
$scope.increment = function(){
$scope.count = count+1;
};
});
</script>
</body>
</html>
Upvotes: 1