Component don't work on my other page

Hello !,i’m having problem with my Component called concessionaria.
error image

i have two pages:

  • Home
  • Lista-favoritos

but my component only works without error in the Home Page.
When i load the component in Lista-Favoritos,give me the error above.

i’m using this code :

      <concessionaria [concessionaria]="concessionaria"></concessionaria>

this code is the same on Home Page

Inside my app.module.ts,i’ve already add my ConcessionariaComponent

The question is,why is working on one page and not in another ?

Thanks for any advice !

Hello,

the error says that your component isn’t know in that page.
Maybe there is a typo anywhere in the import.
Maybe Home is regular loaded and Lista-favoritos is lazy loaded and in *.module import is missing.
Maybe you are importing in lazy loaded …/concessionaria from concessionaria.ts but it should import from concessionaria.modulte.ts into your Lista-Favoritos.module.ts.
Maybe …

By the way you have a component, a property and variable named with the same name? I personnaly find this at late bound speech hard to debug.

Best regards, anna-liebt.

1 Like

Hi @anna_liebt ,thanks !
i see that you’ve big knowledge about Ionic.
i’ve started ionic 1 week ago,so i don’t know exactly the difference about Lazy Loading and Regular Loading.one of them load everything at the same time and other not ?

The Lista-Favoritos Page is one page that ionic created when i generate TABS.
this page has own Lista-Favoritos-Module.ts,but when i add ConcessionariaComponent into Declarations,i receive the message that it is already declared inside the Main Module.
So i don’t know how to make the component works inside that page.
You can see my structure file :
Image Files

in my Lista-Favoritos-Module.ts:

import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { ListaFavoritosPage } from './lista-favoritos';

@NgModule({
  declarations: [
    ListaFavoritosPage,
  ],
  imports: [
    IonicPageModule.forChild(ListaFavoritosPage),
  ],
})
export class ListaFavoritosPageModule {}

i’ve already tried to add ConcessionariaComponent to Declaration.

Maybe you are importing in lazy loaded …/concessionaria from concessionaria.ts but it should import from concessionaria.modulte.ts into your Lista-Favoritos.module.ts.

I Don’t have Concessionaria.module.ts file ,i’ve only components.module.ts ( as you can see in the image file structure)

By the way you have a component, a property and variable named with the same name? I personnaly find this at late bound speech hard to debug.

You Are totally Right !
When i was generating the files i didn’t think about it.But i will fix it to help me in the future with debug.

Thanks Anna for helping me with this trouble !

sorry, misunderstood!

I Solved the problem after 1 day of search !

i was using Lazy Loading(generated by ionic) as @anna_liebt said. i deleted the Lista-Favoritos-module.ts,removed @IonicPage from lista-favoritos.ts and add ListaFavoritosPage to my app.Module.ts

Hello,

fine you solved it. Yes @rapropos can explain it much better.

Bytheway maybe you are using an editor like VS Code. Extensions for VS Code can help with such things like imports and so on.

Best regards, anna-liebt

1 Like