Angularjs 如何在angular 2中使用amcharts的ammaps?
我试图在angular 2应用程序中使用ammaps。 查看代码很明显,我的组件不知道库。Angularjs 如何在angular 2中使用amcharts的ammaps?,angularjs,module,typescript,angular,ammap,Angularjs,Module,Typescript,Angular,Ammap,我试图在angular 2应用程序中使用ammaps。 查看代码很明显,我的组件不知道库。 这就是我的文件的外观: map.component.html <script src="http://www.ammap.com/lib/ammap.js" type="text/javascript"> </script> <script src="http://www.ammap.com/lib/maps/js/worldLow.js" type="text/jav
这就是我的文件的外观:
map.component.html
<script src="http://www.ammap.com/lib/ammap.js" type="text/javascript"> </script>
<script src="http://www.ammap.com/lib/maps/js/worldLow.js" type="text/javascript"></script>
<div id="mapdiv" style="width: 600px; height: 400px;"></div>
}
现在我该怎么做?
这是最新的
谢谢 脚本标记在Angular 2模板中不起作用,但是,您可以将非Angular代码放入索引HTML中,这样就可以了 如果你想在Angular 2中使用代码,你需要导入它并用Ststem.js加载它。您只需要在npm上找到一个可用的AmCharts库 看看这个: 为了便于将来参考,在发布问题之前,您应该使用搜索引擎
import { Component } from '@angular/core';
//saw this on another SO article so that
//typescript does not shout for type not defined
declare var AmCharts: any;
@Component({
selector: 'newsmap-map',
templateUrl: 'app/views/map.component.html',
directives: [],
styleUrls: ['app/css/map.component.css']
})
export class MapComponent {
AmCharts: any;
//using ngOnint to call the required
//javascript that I've pulling in the html file
ngOnInit(){
this.AmCharts = new AmCharts({
makeChart( "mapdiv", {
"type": "map",
"dataProvider": {
"map": "worldLow",
"getAreasFromMap": true
},
"areasSettings": {
"autoZoom": true,
"selectedColor": "#CC0000"
},
"smallMap": {}
} )
}
}