I have created a component "google-map" and installed
npm install @types/googlemaps --save-dev command.Imported component into my declarations still i am getting an error "Template parse errors:
'google-map' is not a known element:
**here is my code**
import { Component, OnInit, ViewChild } from '@angular/core';
declare let google: any;
@Component({
selector: 'google-map',
templateUrl: './google-map.component.html',
styleUrls: ['./google-map.component.scss'],
})
export class GoogleMapComponent implements OnInit {
@ViewChild("map") mapElement;
map:any
constructor() { }
ngOnInit() {
this.initMap();
}
initMap(){
let coords= new google.maps.LatLng(25,80)
let mapOptions:google.maps.MapOptions={
center:coords,
zoom:10,
mapTypeId:google.maps.MapTypeId.ROADMAP
}
this.map= new google.maps.Map(this.mapElement.nativeElement,mapOptions)
}
}
//home.html
<google-map></google-map>
//my app.module.ts looks like
import { StatusBar } from '@ionic-native/status-bar/ngx';
import{GoogleMapComponent} from '../app/google-map/google-map.component'
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
@NgModule({
declarations: [AppComponent,GoogleMapComponent],
entryComponents: [],
//remaing code here//
//系统信息
离子(离子CLI):4.12.0 离子框架:离子角3.9.5 @ ionic / app-scripts:3.2.3科尔多瓦:
cordova(Cordova CLI):8.1.2(cordova-lib@8.1.1) Cordova平台:不可用 Cordova插件:cordova-plugin-ionic-keyboard 2.1.3,cordova-plugin-ionic-webview 1.2.1(和其他25个插件)
系统:
NodeJS:v8.9.4(C:\ Program Files \ nodejs \ node.exe) npm:5.6.0 作业系统:Windows 10