Angular.js&安培;的Adsense [英] Angular.js & Adsense

查看:171
本文介绍了Angular.js&安培;的Adsense的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图把广告放在angular.js应用程序,我已经做了一些阅读和发现了它不可能只是复制并粘贴正常的AdSense code。

I'm trying to put ads on my angular.js app, and I've done some reading and discovered it isn't possible to just copy and paste the normal adsense code.

我听说你都应该在一个transclusion指令包起来,我能找到的这个唯一的例子是另一个岗位#1:
<一href=\"http://stackoverflow.com/questions/15593039/angularjs-and-addthis-social-plugin/16654055#16654055\">AngularJs和AddThis社会插件

I've heard you are supposed to "wrap it in a directive with a transclusion," and the only example I can find of this is another Stackoverflow post: AngularJs and AddThis social plugin

有人能帮助提供有关如何去与谷歌的Adsense这样做指导?

Can someone help give guidance about how to go about doing this with Google Adsense?

推荐答案

您应该做的包装指令,像这样的AdSense剧本...

You should do a wrapper directive to the adSense script like this...

<div data-my-ad-sense>
  <!-- Google AdSense -->
  <script async src="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
  <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) {}
  }
})

这是AdSense异步code。

This is the adSense async code.

这篇关于Angular.js&安培;的Adsense的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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