Skip to main content

Command Palette

Search for a command to run...

How do you load a custom component in ionic 4?

Published
1 min read
How do you load a custom component in ionic 4?

(source : Google)

First create a component

ionic start myProject blank --type=angular  
ionic g module components  
ionic g component components/myComponent --export

This adds both a declaration and export to the components module for “myComponent”.

To use the component just add ComponentsModule to your imports in your page module, e.g.

This way nothing is added to app.module.ts which is how it should be.

Also note if you want to use any components in your own custom components, you need to add IonicModule to the imports in components.module.ts

More from this blog

M

Marvenics | Blog

8 posts

Angular, Ionic Framework, NodeJS & UIUX