title: Executing a function once the page is fully loaded in AngularJS
body: <p>I would like to execute this function as soon as the page is fully loaded.</p>
  
  <pre><code>vm.pointInvoice = () =&gt; {   
      if ($stateParams.property == "INVOICE") {
          vm.invoiceEdit($stateParams.checkin)
          vm.invoiceFocus = true;
          vm.receiptFocus = false;
      }
  }
  </code></pre>
  
  <p>If I put the function as a button (just to test it), everything works perfectly</p>
  
  <pre><code>&lt;button ng-click="vm.pointInvoice()"&gt;OPEN AND POINT TO INVOICE&lt;/button&gt;
  </code></pre>
  
  <p>But, no matter what I do - I simply cannot get this to execute my function automatically (when the page is fully loaded and all data/elements are available).</p>
  
  <p>Lucky me Stack Overflow had a lot of posts about page fully loaded so I tried a whole bunch of them but none of them works, they all fire off the function while the page is still blank. </p>
  
  <p>These are some of the ones I have tried:</p>
  
  <pre><code>$scope.$on('$viewContentLoaded', function(){
      debugger;
  });
  
  angular.element(document).ready(function () {
      debugger;
  });
  
  $scope.$on('$stateChangeSuccess', function () {
      debugger;
  });
  </code></pre>
  
  <p>So my only idea left is to do some ugly <code>setTimeout(function(){ vm.pointInvoice() }, 3000);</code> hack but to me thats a bit like giving up :-D</p>
  
  <p>There MUST be some way to fire off an function when the page is fully loaded....</p>