I’m trying to use a custom component from this ionic3
example in ionic4
: https://www.joshmorony.com/using-google-maps-and-geolocation-in-ionic-with-capacitor/
But I think i’m not adding it to the module correctly. I keep getting this error:
core.js:1673 ERROR Error: Uncaught (in promise): Error: Template parse errors:
'app-google-maps' is not a known element:
1. If 'app-google-maps' is an Angular component, then verify that it is part of this module.
app.module.ts
import { NgModule} from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouterModule, RouteReuseStrategy, Routes } from '@angular/router';
import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { GoogleMapsComponent } from './google-maps/google-maps.component';
@NgModule({
declarations: [AppComponent, GoogleMapsComponent ],
entryComponents: [],
imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule],
providers: [
StatusBar,
SplashScreen,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
],
bootstrap: [AppComponent],
})
export class AppModule {
}
app.component.ts
import { Component, Injector } from '@angular/core';
import { createCustomElement } from '@angular/elements';
import { Platform } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';
import { GoogleMapsComponent } from './google-maps/google-maps.component';
@Component({
selector: 'app-root',
templateUrl: 'app.component.html'
})
export class AppComponent {
constructor(
private platform: Platform,
private splashScreen: SplashScreen,
private statusBar: StatusBar,
private injector: Injector
) {
this.initializeApp();
// convert AppGoogleMaps to customElement
const GoogleMapsElement = createCustomElement(GoogleMapsComponent, {injector} );
// Register the custom element with the browser.
customElements.define('app-google-maps', GoogleMapsElement);
}
initializeApp() {
this.platform.ready().then(() => {
this.statusBar.styleDefault();
this.splashScreen.hide();
});
}
}
any suggestions?