How to load/use ionic directives, if component is declared in a module
Short description of the problem:
I'm using rc0 tabs starter project and I want to have a auth folder with login and signup page inside the src folder (same level as pages).
here's the auth module
@NgModule({
imports:[
FormsModule,
HttpModule
]
declarations:[
LoginPage
]
})
I import the the module in app.module.ts under imports and get
Unhandled Promise rejection: Template parse errors: 'ion-title' is not a known element...
Do I need to import the directives from ionic inside auth module?
What behavior are you expecting?
expecting ionic directive to work globally.
Which Ionic Version? ionic 2 rc.0
try to add your LoginPage into entryComponents
so your example should look like this:
@NgModule({
imports:[
FormsModule,
HttpModule
]
declarations:[
LoginPage
],
entryComponents: [
LoginPage
]
})
Hello, thanks for opening an issue with us! Would you mind posting a repo I can use to reproduce this issue?
@jgw96 here's the repo Github
@ekhmoi adding LoginPage to entryComponents doesn't work either. entryComponents isn't a 'native' property of ngModule from angular isn't it?
Hello, I have the same problem. Are feature componets supported ?
Hey I figured out how to import feature modules correctly to avoid that error. Here's the forum post.
Hope that helps, Dharsan
Hi Dharsan, Thanks!!!
it solves the issue and I agree with the posts over there, that it should be added to the docs immediately. Otherwise, people might start declaring everything inside app.module ignoring ngModules and the many benefits it's gonna bring (hopefully soon also to ionic 2)
For all other readers, you need to use IonicModule.forRoot() method to 'provide' ionic directives to your components:
@NgModule({ imports:[ IonicModule.forRoot(ComponentNeedingIonicDirectives) ], declarations: [ ComponentNeedingIonicDirectives ] })
Juste add IonicModule to the imports. No need to call forRoot for the directive.
@mcherb You saved my day after 5 hours of struggling. In the end it's quiet obvious though ..
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.