JSFiddle - React, Tailwind, and code Playground

by JohannesJo

HTML

<body ng-app="app">
    <div ng-controller='controller'>
        <button ng-click="v()"></button>AAA: {{int}}
         <h1>{{value}}</h1>

         <h2>clicked: {{clicked}}<h2>
         <h2>called: {{called}}</h2>

    </div>
</body>

JavaScript

app = angular.module('app', []);

app.controller('controller', function ($scope, $q, $timeout) {
    $scope.int = 0;
    $scope.clicked = 0;
    $scope.called = 0;
    $scope.v = function () {
        $scope.value = delayed();
        $scope.int = $scope.int + 1;
    };

    $scope.value = delayed();

    function delayed() {
        $scope.clicked = $scope.clicked + 1;
                if (!this.deferred) {
        this.deferred = $q.defer();

            $timeout(function () {
                $scope.called++;
                this.deferred.resolve('monkey!' + $scope.int);
                this.deferred = undefined;
            }, 3500);
        }
        return this.deferred.promise;
    }
});