Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not able to load component into page - Angular 4/Ionic 3

A button is displayed on the page. When the user selects the button the child component will appear, however, the following error appears - Error: Uncaught (in promise): Error: No component factory found for ModalComponent. Did you add it to @NgModule.entryComponents?

The structure I have set up is as follows and this is in conjunction with Ionic 3 -

app (folder) 
 - app.module
 - app.component

components (folder)
 - modal-component.ts

pages (folder)
 - pageOne (folder)
   - pageOne.module
   - pageOne.ts

I put the modal component in the pageOne.module

pageOne.module

@NgModule({
    declarations: [
        pageOne,
        modalComponent

    ],
    entryComponents: [
        modalComponent
    ],
    imports: [
        IonicPageModule.forChild(pageOne),
    ],
    exports: [
        pageOne,

    ]
})
export class pageOneModule {}

pageOne.ts

@IonicPage()

@Component({
  selector: 'pageOne',
  templateUrl: 'pageOne.html',

})
export class pageOne {}
like image 861
userlkjsflkdsvm Avatar asked Jan 08 '18 06:01

userlkjsflkdsvm


1 Answers

Are you bootstrapping your module?

put this somewhere where it will load

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { pageOneModule } from './pages/pageOne/pageOne.module';

document.addEventListener('DOMContentLoaded', () => {
  platformBrowserDynamic().bootstrapModule(pageOneModule)
  .catch(err => console.log(err));
});

I would also suggest using the angular cli, It does this kind of stuff for you.

like image 139
Devcon Avatar answered Oct 31 '22 23:10

Devcon