JSFiddle - React, Tailwind, and code Playground

by Krzysztof Safjanowski

HTML

<div ng-app="app">
    <div ng-controller="count">
        
        count: {{ counter.times }}
        
    </div>
</div>

JavaScript

angular.module('app', [])
.factory('counter', function($interval) {
    var counter = {
        times: 0
    }
    
    return {
        startCounter: function() {
            $interval(function() {
                return counter.times += 1;
            }, 1000);
            return counter
        }
    }
    
})
.controller('count', function($scope, counter) {
  $scope.counter = counter.startCounter();
})