No Google ads in Angular Partials

1,728 views
Skip to first unread message

imehesz

unread,
Feb 23, 2013, 8:41:32 AM2/23/13
to ang...@googlegroups.com
hello,

I'm trying to insert Google Ads in some of my Angular partial-views, but they don't display in the browser. Here are the circumstances:

1- simple and other JS codes are running fine (ie: alert("hello!") or DISQUS and AddThis JS codes are ok. displaying returned content)
2- On the Google Adsense admin page the scripts are registering and reporting as ACTIVE (so adsense's JS seems to be running ok, I guess)
3- I tried to put the JS code in a separate template, load it with jQuery and even put it in an IFRAME, nothing helped
4- there are no error messages in the console.

Has anybody seen anything like this?

thanks,
--iM


Doron Goldberg

unread,
Feb 25, 2013, 6:36:20 AM2/25/13
to ang...@googlegroups.com
Same problem here.

It happens even when I place the ad at index.html.

"Failed to load resource "

Ricardo Trujillo

unread,
Mar 19, 2013, 12:35:17 PM3/19/13
to ang...@googlegroups.com
The same for my app, but in this case with AddThis (http://www.addthis.com/

It happens because when ng-view is used, angularJS load the partial views via Ajax, and maybe some plugins need the page to be reload.

In the case of AddThs social plugin, happens the same, and this is the response of a member of AddThis : If AngularJS uses AJAX to load the pages, If so, then you'll need to add addthis.toolbox() to the callback to make sure the buttons re-render.

No solution still founded at this time.

Anton Pinchuk

unread,
May 20, 2013, 1:48:42 PM5/20/13
to ang...@googlegroups.com
You need to wrap it into a directive with transclusion, check how I did it for AddThis here


суббота, 23 февраля 2013 г., 15:41:32 UTC+2 пользователь imehesz написал:

Pablo Ezequiel Leone Signetti

unread,
Jul 7, 2013, 8:28:51 AM7/7/13
to ang...@googlegroups.com
You should do a wrapper directive to the adSense script like this...

    <div data-my-ad-sense>
      <!-- Google AdSense -->
      <ins class="adsbygoogle"
           style="display:inline-block;width:728px;height:90px"
           data-ad-client="ca-pub-0000000000"
           data-ad-slot="0000000000"></ins>
      <script>
      (adsbygoogle = window.adsbygoogle || []).push({});
      </script>
    </div>

And add this directive to your directives...

    directive('myAdSense', function() {
      return {
        restrict: 'A',
        transclude: true,
        replace: true,
        template: '<div ng-transclude></div>',
        link: function ($scope, element, attrs) {}
      }
    })

This is the adSense async code.

Enrico Icardi

unread,
Apr 22, 2014, 10:56:45 AM4/22/14
to ang...@googlegroups.com
Thanks for that. the code works in my main.html, BUT
can you think of a reason why this shouldn't work in an ng-repeat or inside a template?

thanks,
enrico.

Shuhao Hu

unread,
Mar 17, 2015, 4:38:40 AM3/17/15
to ang...@googlegroups.com


I put adsense in vi-view and  i click a button to redirect to another page with adsense . (press the button repeatly)

during the  four time redirect page, the adsense is show correctly, but next one redirect , the adsnse show empty.

anybody know why?  I guess that adsense's  policy didn't allow to put  more than 3 ad, (adsense  make a misunderstanding that partial view is still one  page )



Enrico Icardi於 2014年4月22日星期二 UTC+8下午10時56分45秒寫道:

Dário Marcelino

unread,
May 21, 2015, 3:32:59 PM5/21/15
to ang...@googlegroups.com
I'm experiencing the same, I've tried different solution (like http://stackoverflow.com/questions/29709973/angular-adsense-ads-not-loading-on-route-change-up-to-3-ads-for-the-entire-app) but ads stop showing after the 3rd one.

Has anyone found a solution/workaround for this?

Reply all
Reply to author
Forward
0 new messages