Execute function after window replace

I send request with angular.js with $http and got some response and after that i must update page and call timer function:

$http({method: 'POST', url: url_api, data: {login_username: username, login_password: password}}).success(function(data, status, headers, config) {
 // parse data
 ....
 window.location.replace("/");
 // call timer
 timer();
}

Where timer:

function timer(){
  document.getElementById("span_count_down").innerHTML = 'Time is out!';
  return;
}

But when i update page, i don't see Time is out! in innerHTML, i see previous innerHTML.

Thank you.

When you call location.replace(), the page is unloaded and no further script is executed. When the new page loads, your script is not executed because it wasn't called on this page.