You can do this with the directive
var adSenseTpl = '<ins class="ad-div adsbygoogle responsive" style="display:inline-block;width:468px;height:60px" data-ad-client="ca-pub-xxxxx" data-ad-slot="xxxxx"></ins></ins>';
angular.module('reviewmattersApp')
.directive('googleAdsense', function($window, $compile) {
return {
restrict: 'A',
transclude: true,
template: adSenseTpl,
replace: false,
link: function postLink(scope, element, iAttrs) {
element.html("");
element.append(angular.element($compile(adSenseTpl)(scope)));
if (!$window.adsbygoogle) {
$window.adsbygoogle = [];
}
$window.adsbygoogle.push({});
}
};
});
In html side
<div google-adsense>
</div>
source
share