0
votes

I have imported { IonicModule } from '@ionic/angular'; and added schemas: [ CUSTOM_ELEMENTS_SCHEMA ] to my component.module.ts file, but am still getting the

"'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." Error.

import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormComponentComponent } from './form-component/form-component.component';

import { IonicModule } from '@ionic/angular';



@NgModule({
  declarations: [FormComponentComponent],
  imports: [
    CommonModule,
    IonicModule
  ],
  schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
})
export class FormModule { }

2
What version of Ionic? - Wesley
"@ionic/angular": "^5.3.2" - Jonathan Soto
You should not have to add any schemas for Angular to recognize ionic elements. That's all taken care of by importing IonicModule. Have you imported IonicModule in your app.module.ts as IonicModule.forRoot()? - Wesley
Yes, I’ve already imported IonicModule in my app.module.ts file. Not sure why it’s not working - Jonathan Soto

2 Answers

0
votes

Try this:

<button ion-button color="primary">Primary</button> 

this will work

0
votes

You need to add

IonicModule.forRoot()

to your imports. not just

IonicModule