ngDfp
ngDfp copied to clipboard
Cannot read property 'apply' of undefined
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?
I haven't seen this error before, could you post a trace?
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]); } });
Very odd, do you have any other library that might be interfering with the googletag variable?
No. I just included the ngDfp, defined slots in app.config and trying to call an mpu on my page
@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
Merged #17. Let us know if that fixes the issue @azizantoun
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
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: