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.
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
Can someone help give guidance about how to go about doing this with Google Adsense?
I am not sure whether doing the following thing is valid as per the adsense T&C.
delete all the google related variables before you change the url
you need to create a directive
create a template with your ads code in my case "partiels/adsTpl.html"
add the directive to your page
place the adSense js call in the head section of your main page before angularjs
et voila , this is work perfectly for me
In the AngularJS controller, add an
init()
function, add a lineThen call this
init()
function in your view html file.See also at
https://github.com/featen/ags/blob/master/webapp/js/controllers/dict.js
You should do a wrapper directive to the adSense script like this...
And add this directive to your directives...
This is the adSense async code.
In the javascript file define a custom directive for google adsense
The adsense information for the above directive is provided by Google when you select the ad. In the page to display ad- use the following tag
In Index.html use the
A video tutorial for getting this up and running is provided here AngularJS + Adsense