AngularJS和AdSense广告未加载路线变化(最多3个广告,整个应用程序) [英] AngularJS and Adsense ads not loaded on route change (up to 3 ads for the entire app)

查看:253
本文介绍了AngularJS和AdSense广告未加载路线变化(最多3个广告,整个应用程序)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个AdSense的角度站点,它会加载第一次加载广告或刷新,但如果我浏览到另一条路线,它不会加载的广告。下面是我使用的指令:

I have an Angular site with AdSense and it will load Ads on first load or refresh, but if I browse to another route, it doesn't load the Ads. Here is the directive I am using:

.directive('googleAdSense', function () {
return {
    restrict: 'A',
    replace: true,
    templateUrl: "../../templates/googleads.html",
    controller: function () {
        (adsbygoogle = window.adsbygoogle || []).push({});
    }
};
});

下面就是我把我的脚本标记索引文件的头。所有视图通过NG-视图加载/列的索引文件:

Here is where I place my script tag in the head of the index file. All views load in/out of the index file via ng-view:

<!-- Google Adsense -->
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

下面是用法:

<div data-google-ad-sense></div>

我怎样才能解决这个所以它加载广告,一旦我去到另一个视图?

How can I resolve this so it loads the Ads once I go to another View?

更新:进一步测试后,只加载前3个广告,这是与谷歌preventing每页3个以上的广告一致....问题是,我有多个这不被视为页面的意见。我想知道如果历史HTML5模式处理有任何与此...

Update: After further testing, it only loads the first 3 ads, which is consistent with Google preventing more than 3 ads per page.... the problem is that I have multiple views that aren't being treated as "pages". I am wondering if HTML5 modes handling of history has anything to do with this...

推荐答案

在这里看到引用(的 https://productforums.google.com/forum/#​​!msg/adsense/Ya498_sUlBE/hTWj64zROoEJ ),但移动脚本标记插入的index.html为我工作。基本上,我使用NG-包括顶部的菜单,有顶部广告脚本标记,那么NG-观点,其次是最后的广告。

See here for reference (https://productforums.google.com/forum/#!msg/adsense/Ya498_sUlBE/hTWj64zROoEJ), but moving the script tags into the index.html worked for me. Basically, I use an ng-include for the top menu, have the script tag for the top ad, then the ng-view, followed by the final ad.

这篇关于AngularJS和AdSense广告未加载路线变化(最多3个广告,整个应用程序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆