What Function to use After DOM and Data is ready and loaded


#1

I use the basic .js structure as created in the angular-meteor tutorial for all my projects. Meteor 1.3 and Angularjs, blaze is removed.

**My question is: **
, what callback can I use to trigger a function when the DOM and the data is ready and loaded. I have tried the following function (Shown in the example below):

 - $timeout(function(){
   //////Code inserted here
  }, 1000); **This works (Sort of), takes to long to load and I am not sure that this will always work....**

 - angular.element($document).ready(function () {
    /////Code inserted 
   }); **This doesn`t work, always triggers before the data is available.**

 - angular.element($window).load(function () {
   //////Code inserted
  }); **This doesn`t work, always triggers before the data is available.**

Structure of my .js looks like the example below:

import angular from 'angular';
import angularMeteor from 'angular-meteor';

class Something {
    constructor($scope, $reactive, .......) {
       'ngInject';

          $reactive(this).attach($scope);

          this.subscribe('someCollection');

          this.helpers({
              dbcollect() {
                    return SomeCollection.find({});
                          });

            **////I insert my callback functions here, and looks like:**
             $timeout(function(){
             var itemsincollection = dbcollect.length; _///I need to be able to work with this data as specified                                 in the helpers above;_
             },1000);  **/////As mentioned above this works, but I don`t think it is always guaranteed to work**
         }
}

const name = Something;

//create module
export default angular.module(name, [
angularMeteor,
......]).comnponent(name, {
         templateUrl : '',
         controllerAs : name,
         controller     : SitesList
})
.config(config)
.run(run);