ディレクティブを作成する必要があります
yourApp.directive('ads', function() {
return {
restrict: 'A',
templateUrl: 'partiels/adsTpl',
controller: function(){
(adsbygoogle = window.adsbygoogle || []).push({});
}
};
});
私の場合は「partiels/adsTpl.html」という広告コードでテンプレートを作成します
<ins class="adsbygoogle"
style="display:inline-block;width:300px;height:250px"
data-ad-client="ca-pub-00000000"
data-ad-slot="000000"></ins>
ページにディレクティブを追加します
<div data-ads></div>
angularjs の前に、メイン ページの head セクションに adSense js 呼び出しを配置します。
<head>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
....
et voila 、これは私にとって完璧に機能します