I want to use a javascript setTimeout with AngularJS, that count value increases after every second:
<!DOCTYPE html>
<html>
<head>
<title>MyCount</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="js/angular.min.js"></script>
<script type="text/javascript">
How to write correctly
function myController($scope) {
$scope.count = 1;
$scope.delayInc = function () {
$timeout(function () {
$scope.count += 1;
}, 1000);
};
}
</script>
That the count does not stay to 1?
<h2>My Second Count: {{count}}</h2>
</body>
</html>
Thank you