我試圖讓和冰組成的角4,它不會讓我呈現地圖所有..無法讀取空Bing地圖的特性「原型」和Angualar4
這是我的index.html文件:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Microsoft</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<script type='text/javascript' src='http://www.bing.com/api/maps/mapcontrol?branch=experimental'></script>
</head>
<body onload="AppComponent.helloWorld()">
<div id="myMap"></div>
<app-root></app-root>
</body>
</html>
這是我的組件:
export class AppComponent implements OnInit {
@ViewChild('myMap') myMap;
title = 'app';
ngOnInit() {
if(Microsoft !== undefined){
var map = new Microsoft.Maps.Map(this.myMap.nativeElement, {
credentials: 'key goes here'
});
}}
}
組件的HTML文件:
<div #myMap style='width: 100%; height: 500px;'></div>
我不知道我在做什麼錯。但我無法獲取地圖加載。它的引發無法讀取null錯誤的屬性'原型'。
什麼是onload =「AppComponent.helloWorld()?它是否運行? – Vega