0

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.

2 Answers 2

1

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>
Sign up to request clarification or add additional context in comments.

Comments

0

try putting $scope.count = 0; in your controller

2 Comments

No effect. Any other possible ways?
try putting in the html <button ng-click="myCtrl.count ++">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.