Lala
Lala

Reputation: 29

Not able to import IonicModule from path

I am fairly new to Angular and typescript but I have an Angular 6 project using Ionic 3 elements.

I am trying to import a library that is saved locally from the cdn from path ../lib/ionic.bundle.js into my project but I get template parse errors which indicates the module is not imported for that path.

Error: Template parse errors:
'ion-card-header' is not a known element:
1. If 'ion-card-header' is an Angular component, then verify that it is part of this module.
2. If 'ion-card-header' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
<ion-card>


import { IonicApp, IonicModule } from '../lib/ionic.bundle.js';
const routes: Routes = [
  {
    path: 'create',
    component: CreateComponent
  },
  {
    path: 'edit/:id',
    component: EditComponent
  },
  {
    path: 'index',
    component: IndexComponent
  }
];

@NgModule({
  declarations: [
    CreateComponent,
    IndexComponent,
    EditComponent,
  ],
  imports: [
    IonicModule.forRoot(routes)
  ],
  providers: [ ...]
})
export class AppModule { }

I am sure the file exists at that path but not being imported from some reason.

Is there a different way of importing the IonicModule?

Upvotes: 0

Views: 1022

Answers (1)

O.O
O.O

Reputation: 1419

You should try importing it from node_modules instead.

In command line in your project dir:

$ npm i ionic

After its installed ionic, then try importing from ionic-angular:

import { IonicModule } from 'ionic-angular'

Upvotes: 1

Related Questions