# Ionic components inside custom component ionic-v4

**URL:** <https://forum.ionicframework.com/t/ionic-components-inside-custom-component-ionic-v4/140003>\
**Category:** Ionic Framework\
**Created:** [August 28, 2018, 11:47am UTC](https://forum.ionicframework.com/t/ionic-components-inside-custom-component-ionic-v4/140003 "2018-08-28T11:47:52Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![anupzone](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/anupzone/32/120703_2.png) [@anupzone](https://forum.ionicframework.com/u/anupzone)\
**Post date:** [August 28, 2018, 11:47am UTC](https://forum.ionicframework.com/t/ionic-components-inside-custom-component-ionic-v4/140003/1 "2018-08-28T11:47:52Z")

</div>

How to use ionic components in custom component? I have created component and i want to use `<ion-header>` on that and giving error obviously. so how and where have to import ionic components in custom component?

---

<div class="post-metadata">

**Author:** ![HinderiksR](https://avatars.discourse-cdn.com/v4/letter/h/9dc877/32.png) [@HinderiksR](https://forum.ionicframework.com/u/HinderiksR)\
**Post date:** [August 28, 2018, 12:23pm UTC](https://forum.ionicframework.com/t/ionic-components-inside-custom-component-ionic-v4/140003/2 "2018-08-28T12:23:24Z")

</div>

Which error does it give ?

---

<div class="post-metadata">

**Author:** ![anupzone](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/anupzone/32/120703_2.png) [@anupzone](https://forum.ionicframework.com/u/anupzone)\
**Post date:** [August 28, 2018, 12:26pm UTC](https://forum.ionicframework.com/t/ionic-components-inside-custom-component-ionic-v4/140003/3 "2018-08-28T12:26:19Z")

</div>

```auto
'ion-header' is not a known element:
1. If 'ion-header' is an Angular component, then verify that it is part of this module.
2. If 'ion-header' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("[ERROR ->]<ion-header>
  <ion-title>

```

---

<div class="post-metadata">

**Author:** ![HinderiksR](https://avatars.discourse-cdn.com/v4/letter/h/9dc877/32.png) [@HinderiksR](https://forum.ionicframework.com/u/HinderiksR)\
**Post date:** [August 28, 2018, 12:30pm UTC](https://forum.ionicframework.com/t/ionic-components-inside-custom-component-ionic-v4/140003/4 "2018-08-28T12:30:14Z")

</div>

hmm ok, As far as i know you dont have to import ionic components. Could you post the .ts files and .html files of your custom component ?

---

<div class="post-metadata">

**Author:** ![anupzone](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/anupzone/32/120703_2.png) [@anupzone](https://forum.ionicframework.com/u/anupzone)\
**Post date:** [August 28, 2018, 12:31pm UTC](https://forum.ionicframework.com/t/ionic-components-inside-custom-component-ionic-v4/140003/5 "2018-08-28T12:31:24Z")

</div>

header-outer.component.ts

```auto
import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-header-outer',
  templateUrl: './header-outer.component.html',
  styleUrls: ['./header-outer.component.scss']
})
export class HeaderOuterComponent implements OnInit {

  constructor() { }

  ngOnInit() {
  }

}

```

header-outer.component.html

```auto
<ion-header>
  <ion-title>abcd</ion-title>
</ion-header>

```

---

<div class="post-metadata">

**Author:** ![HinderiksR](https://avatars.discourse-cdn.com/v4/letter/h/9dc877/32.png) [@HinderiksR](https://forum.ionicframework.com/u/HinderiksR)\
**Post date:** [August 28, 2018, 12:35pm UTC](https://forum.ionicframework.com/t/ionic-components-inside-custom-component-ionic-v4/140003/6 "2018-08-28T12:35:53Z")

</div>

Do other ion components work and is this the only one that doesnt work ?

---

<div class="post-metadata">

**Author:** ![anupzone](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/anupzone/32/120703_2.png) [@anupzone](https://forum.ionicframework.com/u/anupzone)\
**Post date:** [August 28, 2018, 12:36pm UTC](https://forum.ionicframework.com/t/ionic-components-inside-custom-component-ionic-v4/140003/7 "2018-08-28T12:36:24Z")

</div>

all ionic components not working

---

<div class="post-metadata">

**Author:** ![HinderiksR](https://avatars.discourse-cdn.com/v4/letter/h/9dc877/32.png) [@HinderiksR](https://forum.ionicframework.com/u/HinderiksR)\
**Post date:** [August 28, 2018, 1:07pm UTC](https://forum.ionicframework.com/t/ionic-components-inside-custom-component-ionic-v4/140003/8 "2018-08-28T13:07:59Z")

</div>

Incase you upgraded from ionic 3 to 4 i advise you to follow the migration guide: [https://beta.ionicframework.com/docs/building/migration](https://beta.ionicframework.com/docs/building/migration)

Their are other ones out there.

If this is a new project i’ve got no idea whats going on and i’m sorry but i cant help you

---

<div class="post-metadata">

**Author:** ![anupzone](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/anupzone/32/120703_2.png) [@anupzone](https://forum.ionicframework.com/u/anupzone)\
**Post date:** [August 28, 2018, 1:09pm UTC](https://forum.ionicframework.com/t/ionic-components-inside-custom-component-ionic-v4/140003/9 "2018-08-28T13:09:42Z")

</div>

already have latest one. i think u didnt understand my query. i m using custom component, not page.

---

<div class="post-metadata">

**Author:** ![reedrichards](https://avatars.discourse-cdn.com/v4/letter/r/34f0e0/32.png) [@reedrichards](https://forum.ionicframework.com/u/reedrichards)\
**Post date:** [August 28, 2018, 3:12pm UTC](https://forum.ionicframework.com/t/ionic-components-inside-custom-component-ionic-v4/140003/10 "2018-08-28T15:12:05Z")

</div>

Plz post the code of the module related to HeaderOuterComponent  
Or double check that you import `IonicModule` in that module

---

<div class="post-metadata">

**Author:** ![anupzone](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/anupzone/32/120703_2.png) [@anupzone](https://forum.ionicframework.com/u/anupzone)\
**Post date:** [August 28, 2018, 3:17pm UTC](https://forum.ionicframework.com/t/ionic-components-inside-custom-component-ionic-v4/140003/11 "2018-08-28T15:17:04Z")

</div>

![10%20pm](https://global.discourse-cdn.com/ionicframework/original/3X/f/9/f9d28aca1e35d1090b0e57ce2925c10e5283cba7.png)  
no module page created by ionic. need to create one?

---

<div class="post-metadata">

**Author:** ![anupzone](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/anupzone/32/120703_2.png) [@anupzone](https://forum.ionicframework.com/u/anupzone)\
**Post date:** [August 28, 2018, 3:29pm UTC](https://forum.ionicframework.com/t/ionic-components-inside-custom-component-ionic-v4/140003/12 "2018-08-28T15:29:12Z")

</div>

ok its working now 😀  
imported `import { IonicModule } from '@ionic/angular';` in component.module.ts  
thanks 🙂

---

<div class="post-metadata">

**Author:** ![reedrichards](https://avatars.discourse-cdn.com/v4/letter/r/34f0e0/32.png) [@reedrichards](https://forum.ionicframework.com/u/reedrichards)\
**Post date:** [August 28, 2018, 3:32pm UTC](https://forum.ionicframework.com/t/ionic-components-inside-custom-component-ionic-v4/140003/13 "2018-08-28T15:32:07Z")

</div>

Was about to answer that, coolio

---

<div class="post-metadata">

**Author:** ![juanariaswayne](https://avatars.discourse-cdn.com/v4/letter/j/c68b51/32.png) [@juanariaswayne](https://forum.ionicframework.com/u/juanariaswayne)\
**Post date:** [September 19, 2018, 3:32pm UTC](https://forum.ionicframework.com/t/ionic-components-inside-custom-component-ionic-v4/140003/14 "2018-09-19T15:32:16Z")

</div>

Hi! Ive the same problem… Where you imported this **import { IonicModule } from ‘@ionic/angular’;?**

I need to create a new archive in my component?

![Captura](https://global.discourse-cdn.com/ionicframework/original/3X/0/2/02381495e5776d6480d164cfba206a38aed0a983.jpeg)

---

<div class="post-metadata">

**Author:** ![anupzone](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/anupzone/32/120703_2.png) [@anupzone](https://forum.ionicframework.com/u/anupzone)\
**Post date:** [September 19, 2018, 5:02pm UTC](https://forum.ionicframework.com/t/ionic-components-inside-custom-component-ionic-v4/140003/15 "2018-09-19T17:02:53Z")

</div>

in common module file for all components. where u imported all components.

---

<div class="post-metadata">

**Author:** ![juanariaswayne](https://avatars.discourse-cdn.com/v4/letter/j/c68b51/32.png) [@juanariaswayne](https://forum.ionicframework.com/u/juanariaswayne)\
**Post date:** [September 19, 2018, 5:23pm UTC](https://forum.ionicframework.com/t/ionic-components-inside-custom-component-ionic-v4/140003/16 "2018-09-19T17:23:43Z")

</div>

Sorry! I cant find this file… I feel like a dumb ☹

This is my proyect… Where I could find this file to put the import?

 ![Captura2](https://global.discourse-cdn.com/ionicframework/original/3X/2/9/29e84097526a44e665b88ea3b04385f4276c1ece.jpeg)

Thank you so much!!

---

<div class="post-metadata">

**Author:** ![anupzone](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/anupzone/32/120703_2.png) [@anupzone](https://forum.ionicframework.com/u/anupzone)\
**Post date:** [September 19, 2018, 8:03pm UTC](https://forum.ionicframework.com/t/ionic-components-inside-custom-component-ionic-v4/140003/17 "2018-09-19T20:03:02Z")

</div>

![56%20am](https://global.discourse-cdn.com/ionicframework/original/3X/4/8/48aa9af263bb4f38050663b2c0df6fad6a017504.png)

```auto
import { NgModule } from '@angular/core';
import { IonicModule } from '@ionic/angular';
import { HeaderInnerComponent } from './header-inner/header-inner.component';
import { HeaderOuterComponent } from './header-outer/header-outer.component';
import { HeaderBodyComponent } from './header-body/header-body.component';
import { HeaderLoginComponent } from './header-login/header-login.component';
import { FooterCommonComponent } from './footer-common/footer-common.component';

@NgModule({
  declarations: [
    HeaderInnerComponent,
    HeaderOuterComponent,
    HeaderBodyComponent,
    HeaderLoginComponent,
    FooterCommonComponent
  ],
  exports: [
    HeaderInnerComponent,
    HeaderOuterComponent,
    HeaderBodyComponent,
    HeaderLoginComponent,
    FooterCommonComponent
  ],
  imports: [
    IonicModule
  ]
})
export class ComponentsModule {}

```

and this component.module.ts call in every page.module.ts where you want to use component. like this:

```auto
import { ComponentsModule } from '../components/component.module';

```

---

<div class="post-metadata">

**Author:** ![juanariaswayne](https://avatars.discourse-cdn.com/v4/letter/j/c68b51/32.png) [@juanariaswayne](https://forum.ionicframework.com/u/juanariaswayne)\
**Post date:** [September 26, 2018, 8:30pm UTC](https://forum.ionicframework.com/t/ionic-components-inside-custom-component-ionic-v4/140003/18 "2018-09-26T20:30:04Z")

</div>

It works!! Thank you so much!!

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:22pm UTC](https://forum.ionicframework.com/t/ionic-components-inside-custom-component-ionic-v4/140003/19 "2021-07-19T21:22:25Z")

</div>


