0

I want to specifically use element.onload(function(){}) for when the element is completedly loaded in compile's poststep. But I saw the elem inside compile include onload as null so basically onload does not exist for angular element. I found .ready attached to the element function though, but is this equivalent?

My scenario: Basically I have a directive contains google ad, and I include it with another directive using ng-transclude, that, transclude the google ad directive into it.

I want to see if there is a way to determine exact moment when the ad is completely loaded, I thought onload for the dom is a good option, but I can't find that equivalent inside angular directive's elem argument in compile stage, which supposedly the stage where all dom should be rendered?

ey dee ey em
  • 7,991
  • 14
  • 65
  • 121
  • Don't think so. Angularjs is SPA (single page application), and it loads views (I.E other HTMLs) when you navigate from one state to another so the DOM can always be `ready` and `load`ed, that's why you need to be more specific about why you need this in the first place (Pretty sure there is a pure angular solution for what you're trying to achieve) – Alon Eitan Jul 14 '16 at 21:21
  • @AlonEitan added my scenario – ey dee ey em Jul 14 '16 at 21:25
  • Would [this answer](http://stackoverflow.com/a/23948165/754119) be of any help? – Alon Eitan Jul 14 '16 at 21:26

1 Answers1

0

this is the way to go :

var $scope.init = function(){
 //your code`enter code here`
}