Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic button showing 'ion-button' is not a known element

Tags:

I am new to ionic, it seems like a silly question but I need some help Using some simple button is throwing error. I am using ionic 4.0.

'ion-button' is not a known element: 1. If 'ion-button' is an Angular component, then verify that it is part of this module. 2. If 'ion-button' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.

<ion-button color="primary">Primary</ion-button> 
like image 965
anubhab Avatar asked Jul 26 '18 17:07

anubhab


Video Answer


2 Answers

Try this,

<button ion-button color="primary">Primary</button> 
like image 136
Mangesh Daundkar Avatar answered Sep 21 '22 08:09

Mangesh Daundkar


In order to avoid that error message:

  1. Import CUSTOM_ELEMENTS_SCHEMA into app.modules.ts:
    import { ErrorHandler, NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; 
  1. Add schema: [CUSTOM_ELEMENTS_SCHEMA] to app.modules.ts as below:
    @NgModule({       declarations: [         MyApp,         HomePage       ],       imports: [         BrowserModule,         HttpClientModule,         MomentModule,         IonicModule.forRoot(MyApp),       ],       bootstrap: [IonicApp],       entryComponents: [         MyApp,         HomePage       ],       providers: [         StatusBar,         SplashScreen,         {provide: ErrorHandler, useClass: IonicErrorHandler},       ],       schemas: [CUSTOM_ELEMENTS_SCHEMA]     }) 
like image 23
Gerry R Avatar answered Sep 19 '22 08:09

Gerry R