Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I pass a custom callback function of my own? #41

Open
mihaisavezi opened this issue Jan 28, 2016 · 1 comment
Open

Can I pass a custom callback function of my own? #41

mihaisavezi opened this issue Jan 28, 2016 · 1 comment

Comments

@mihaisavezi
Copy link

I'm reading through the sourcecode and looking for a way to pass a callback function to check after the slot has rendered if it is empty, with the isEmpty method available on DFP.

I found where I can call that method in the source, but I'm looking for a way to pass a callback function when I define a slot.

Not an issue with the library, it does what it says. I'm trying to take a stab at this myself, but I can't see how it can be done.

Did anyone try this?

e.g. in my case, because currently the directives data-ng-dfp-ad-hide-when-empty data-ng-dfp-ad-container are not working for me and I need to hide my container.

I apologise if this is not the place for such questions, as it's not a technical issue more of a " does this feature exist " kind of thing.

@mihaisavezi
Copy link
Author

I just realised that you can use other elements of the DFP API on your own, without using ng-dfp.

In my case, I could add an event listener for the slot in the controller associated with that slot. Like this:

googletag.cmd.push(function() {
            googletag.pubads().addEventListener('slotRenderEnded', function(event) {
                if(event.isEmpty) {
                    $scope.isEmpty = true;
                }
            });
        })

Sure it's not the most elegant thing, but it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant