I've created a component and I want to include it in my page but is not working because a error messages appears
No provider for MyExample
I already added the component to the app.module.ts
in the entryComponents
and declarations
sections.
My example component src/app/components/my-example/my-example.ts
import { Component } from '@angular/core';
@Component({
selector: 'my-example',
templateUrl: 'my-example.html'
})
export class MyExample {
constructor() {
console.log('Constructor...');
}
}
app.module.ts src/app/app.module.ts
import { MyExample } from '../components/my-example/my-example';
@NgModule({
declarations: [MyExample],
bootstrap: [IonicApp],
....
entryComponents: [MyExample]
})
My page src/app/pages/my-page/my-page.ts
import { MyExample } from '../../components/my-example/my-example';
@Component({
selector: 'purchase-page',
templateUrl: './purchase.html'
})
......
The path is correct because in the app.module.ts I can display the content of the component with console.log(MyExample);
and it's working perfectly.
I'm using Ionic 2 RC4.
Kind regards!
I fixed it including the component within a @ViewChild