Placing Amazon Banner | Angular V4

China☆狼群 提交于 2019-12-06 14:09:18

After scrapping every post in SO regarding or similar to this question I did not find any solution to this.I followed almost everything in those posts but nothing was working for me.After that I came across postscribe library which does the externally loading of any third party script.

First I installed the library and imported it in my component

import * as postscribe from 'postscribe';

After that all I did was calling a function inside my ngAfterViewInit function, by targetting the div with its id which in my case was adv and passed the script as a second parameter to this function.

ngAfterViewInit() {
postscribe('#adv', `<script type="text/javascript" language="javascript">
                       var aax_size='728x90';
                       var aax_pubname = 'XXXXXXXX';
                       var aax_src='302';
                    </script>
                    <script type="text/javascript" language="javascript" src="http://c.amazon-adsystem.com/aax2/assoc.js"></script>`);}

By doing this my banner was loaded.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!