Ionic 4 questions on app.modules setup


#1

Hi, i feel confuse about the declarations, app.modules.ts. Here is my situation.

I have a page Home.page.ts, a headerComponent and a filterModal.page.ts, the Modal will be called in the headerComponent.

First, i have import the page in the app.modules like below.

**app.modules.ts**
@NgModule({
  declarations: [
    ...
    filterModal // need to remove if build in --prod
  ],
  entryComponents: [filterModal],

Second i have set the page in the headerComponent and use the modalCtrl to call it out.

**headerComponent.ts**
import {filterModal} from '....';

async show(){
    this.modal = await this.modalCtrl.create({
      component: filterModal
    })
    return await this.modal.present();
  }

Third just import the headerComponent in the Home page

So here is the problem, In above setup, i can run it on local browser for testing without error. But if i build it in --prod flag, it will get me a error like is part of the declarations of 2 modules:.
And i need to remove the declarations in app.modules.ts but after it removed, i cant view on local browser with this error Component FilterPage is not part of any NgModule or the module has not been imported into your module.

I am not sure which one is correct, the filterModal will only used on the HomePage.