I have a Yandex map widget and I want to embed it in an Angular component. I am using Angular(v6)
I tried to embed scripts and the root element in a tree:
ngAfterViewInit() {
this.renderMapWidget();
}
renderMapWidget() {
const ymapsScript = document.createElement('script');
ymapsScript.src = '//api-maps.yandex.ru/2.1/?load=package.standard&lang=ru_RU';
const ymapsWidgetScript = document.createElement('script');
ymapsWidgetScript.src = '//...............';
setTimeout(() => {
document.body.appendChild(ymapsScript);
document.body.appendChild(ymapsWidgetScript);
}, 2000);
}
template:
<div id="widget-container"></div>
Inspecting the widget in Chrome shows that the widgets root element is displayed, but the element is empty. Also I am not seeing any errors in the console output.