arkade arkade - 1 year ago 233
TypeScript Question

Uncaught (in promise): Error: Template parse errors: 'ion-col' is not a known element

I am trying to create a custom component in ionic 3 but i do not seem to know how to setup the components.module properly so that i can use the ionic components in my component

i generated the component like so

$: ionic g component my-component


When i add

<ion-row>
<ion-col>
</ion-col>
</ion-row


to
my-component.html
i get the error


Uncaught (in promise): Error: Template parse errors: 'ion-col' is not
a known element

Answer Source

Using

ionic generate component my-component

It'll automatically be declared inside the shared module components.module.ts under the components folder.

So if you need to use that component, just import above shared module inside your page's module.

components.module.ts (shared)

 import { IonicPageModule } from 'ionic-angular';

 @NgModule({
    declarations:[MyComponentComponent],
    imports:[
       IonicPageModule.forChild(MyComponentComponent)  // <- Add
    ],
    exports: [MyComponentComponent]
 })
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download