JSFiddle - React, Tailwind, and code Playground
HTML
<div ng-app="myApp" ng-controller="myVm">
{{currentCount}}
</div>
JavaScript
angular.module("myApp",[]);
angular.module("myApp").controller("myVm",
function($scope,$http,$interval) {
var count = 0;
function getHttpPromise(url) {
var promise = $http.post(url);
//return for chaining
return promise;
};
function updateScope(promise) {
//chain from promise
promise.then (function (response) {
count++;
$scope.currentCount = "Current response "+count;
});
};
updateScope(getHttpPromise("/echo/json"));
var intervalPromise = $interval( function(){
updateScope(getHttpPromise("/echo/json"));
}, 1000 );
});