Uknown elemnt ionic 6

hi guy i have problem here in my code i created shared module for 2 component but if i wanna use the component in an other pages in ionic but the compiler it write unknown element ! i dont know why i export 2 component in shared module for use in any place in project !!

You need to declare the component in the parent module.

1 Like

Are you building angular project?

Hills’s comment means you need to declare the components that you want to share in the corresponding modules, this is angular-specific setup.

Then import the “library module” in the module of the “consumer component”.

For example:

In library module:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
@NgModule({
  imports:      [ BrowserModule ],
  providers:    [ ],
  declarations: [ AppSlidesComponent, AppStartButtons ],
  exports:      [ AppSlidesComponent, AppStartButtons ],
})
export class AppLibModule { }

In the consumer module:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
@NgModule({
  imports:      [ BrowserModule, AppLibModule ],
  providers:    [ ],
  declarations: [ WelcomePageComponent ],
  exports:      [ WelcomePageComponent ],
})
export class WelcomeModule { }
1 Like