title: $(document).ready alternative for AngularJS
body: <p>I'm using a template called Gentelella and I'm trying to implement AngularJS into it. However, I'm having an issue with a certain Javascript file. In the end of this file, a <code>$(document).ready</code> function is called which initialises Javascript code that makes some changes in the HTML code. The issue is that the <code>$(document).ready</code> function is called too early, before the HTML is fully loaded. </p>
  
  <p>This issue occurs probably because I'm using ngRoute and this injects the template html file into the ng-view of the index.html. When this happens, the DOM probably already announces a document ready before AngularJS has injected the template (=HTML).</p>
  
  <p>So basically, I just need to find a way to call some code in a Javascript file once AngularJS has injected the template.</p>
  
  <p>I attached some code to gain some insight into the issue:</p>
  
  <p>Snippet of the custom.min.js</p>
  
  <pre><code>$(document).ready(function () {
    init_sparklines(), init_flot_chart(), init_sidebar(), init_wysiwyg(), init_InputMask(), ...
  });
  </code></pre>
  
  <p>Snippet of the main.js:</p>
  
  <pre><code>.config(function($routeProvider, $httpProvider) {
  
    $routeProvider.when('/', {
      templateUrl : 'dash.html',
      controller : 'dash',
      controllerAs: 'controller'
    }).when('/login', {
      templateUrl : 'login.html',
      controller : 'navigation',
      controllerAs: 'controller'
    }).when('/plain_page', {
      templateUrl : 'plain_page.html',
      controller : 'dash',
      controllerAs: 'controller'
    }).otherwise('/');
  
    $httpProvider.defaults.headers.common["X-Requested-With"] = 'XMLHttpRequest';
  
  })
  </code></pre>
  
  <p>Thanks in advance!</p>