angularjs - Adding auto refresh after a particular interval (5 seconds) in angular js -


i have page in which has multiple tabs. want add feature tab reloaded automatically after fixed duration. have following:

<uib-tab index="$index + 1" ng-repeat="environmentregiontab in ctrl.environmentregiontabs"          heading="{{environmentregiontab.environmentregionname}}"          select="ctrl.onenvironmentregionselect(environmentregiontab.id);">     <div class="panel-body tab-content">         <div class="alert alert-success" ng-show="ctrl.deploystatus[ctrl.environmentregion.name].show">             <strong>launched deployment execution id                 {{ctrl.deploystatus[ctrl.environmentregion.name].id}}</strong>         </div>  ................... 

and following controller:

export function servicedetailcontroller(ecsserviceresponse, teamlistresponse, productlistresponse, businesssubownerlistresponse, serviceinstancesresponse, businessownerlistresponse, ecsservice, secretsservice, $location, $stateparams, $uibmodal, $scope, $state, $window) {     'nginject';     var self = this;     var serviceinstanceid; self.ecsauthcontrol = {}; self.initialize = _initialize; self.clearmessages = _clearmessages(); self.onenvironmentregionselect = _onenvironmentregionselect;  $scope.reloadroute = function() {     $state.reload(); };  function _onenvironmentregionselect(serviceinstanceid) {     self.selectedserviceinstanceid = serviceinstanceid;     if (serviceinstanceid) {         $location.search('serviceinstanceid', serviceinstanceid);         _loadenvironmentregion();     } else {         $location.search('serviceinstanceid', null);         _loadsummary();     } }  } 

i not able understand how add fixed time duration? show counter ticking down 5 0 after page reloaded. how can it? declared reload function not able figure out how add fixed timer? thanks!

make use of $interval service in angularjs:

$interval(function () {    $scope.reloadroute(); }, 5000); 

(make sure pass $interval dependency controller)

example plunker


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -