https://stackoverflow.com/questions/44523681

https://stackoverflow.com/questions/44523681

by Daan De Smedt

HTML

<div ng-app="app" ng-controller="MainController as vm">
  {{vm.message}}
  <br>
  <button ng-click="vm.myFunc()">OK</button>
</div>

JavaScript

angular
  .module('app', [])
  .controller('MainController', MainController)


function MainController($timeout) {

  var vm = this;
  vm.myFunc = myFunc;
  vm.message = "Waiting 2000ms for update";

  function myFunc() {
    vm.message = "Timeout called!";
  }

  $timeout(myFunc, 500);

}