ngDfp icon indicating copy to clipboard operation
ngDfp copied to clipboard

Cannot read property 'apply' of undefined

Open azizantoun opened this issue 9 years ago • 8 comments

Hello, I'm getting this error in my browser's console,randomly. And when this error is thrown, the ads are not loading. Any idea why?

azizantoun avatar Jul 06 '15 10:07 azizantoun

I haven't seen this error before, could you post a trace?

ianmurrays avatar Jul 06 '15 11:07 ianmurrays

this._initialize = function () { angular.forEach(slots, function (slot, id) {

------>>>>>>> The error is caused here. googletag.defineSlot is undefined, this is why the error is thrown. PS: It doesn't always show, it's very random, but when it does, ads do not load. definedSlots[id] = googletag.defineSlot.apply(null, slot).addService(googletag.pubads()); --------->>>> if(sizeMapping[id]){ definedSlots[id].defineSizeMapping(sizeMapping[id]); } });

azizantoun avatar Jul 06 '15 11:07 azizantoun

Very odd, do you have any other library that might be interfering with the googletag variable?

ianmurrays avatar Jul 06 '15 11:07 ianmurrays

No. I just included the ngDfp, defined slots in app.config and trying to call an mpu on my page

azizantoun avatar Jul 06 '15 11:07 azizantoun

@azizantoun Let me know if https://github.com/ianmurrays/ngDfp/pull/17 fixes your issue. The error happens when the gpt.js isn't loaded in time to execute .defineSlot(). https://developers.google.com/doubleclick-gpt/reference#googletag.cmd

cc/ @ianmurrays

oitozero avatar Jul 13 '15 16:07 oitozero

Merged #17. Let us know if that fixes the issue @azizantoun

ianmurrays avatar Jul 13 '15 16:07 ianmurrays

Wow! Thank you for the quick response. It actually fixed the previous issue but now getting another error, (again randomly, not every time I reload my page) TypeError: $window.googletag.display is not a function

azizantoun avatar Jul 14 '15 07:07 azizantoun

Yep, seems I was experiencing this bug as well, was only loading the ads after a few hard refreshes, I noticed a sudden drop in impressions which led me to believe there's a bug here, updated now, let's see if it bounces back up. Ohh the joys of Angular :) :100:

ovox avatar Aug 08 '15 22:08 ovox