阻止Angular应用程序,直到CDN Js依赖关系得到解决

时间:2017-08-26 12:25:37

标签: angular webpack angular-cli bing-maps

如何在解析js依赖关系(Bing maps)之前阻止启动Angular应用程序?

如果在加载angular app js bundle(main bundle.js)之前还有其他方法加载cdn js依赖(defer / async / preload),我真的很感激。

1 个答案:

答案 0 :(得分:0)

假设您同步加载Angular,可以使用callback from Bing maps触发角度bootstrap

var map;
function loadMapScenario() {
    map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
        credentials: 'Your Bing Maps Key'
    });
    platformBrowserDynamic().bootstrapModule(AppModule);
}
<script type='text/javascript' src='https://www.bing.com/api/maps/mapcontrol?callback=loadMapScenario' async defer></script>
<div id='myMap' style='width: 100vw; height: 100vh;'></div>