Fixed bug calling trigger before DOM is loaded (AngularJS 1.3)