I'm working on a generic Ionic 2 app which consist in loading and displaying multiple components on the first page.
Each add-ons need to be easily created and implemented in the app very easily. So I created a file named "addon-declaration.ts". Inside this file, I exported all my components :
export { MyFirstAddon } from './components/addon1/first.addon';
export { MySecondAddon } from './components/addon2/second.addon';
export { MyThirdAddon } from './components/addon3/third.addon';
So my question is how to import all my components directly on "app.module.ts" declarations field ?
I already tried this but it's not working :/
import * as ModuleHandler from '../models/addons/addon-declaration';
@NgModule({
declarations: [
MyApp,
ModuleHandler <--- Not working
],
imports: [
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp
],
providers: [{provide: ErrorHandler, useClass: IonicErrorHandler}]
})
export class AppModule {}
It's working nice if I import them one by one :
import { MyFirstAddon } from'../components/addon1/first.addon';
import { MySecondAddon } from'../components/addon2/second.addon';
import { MyThirdAddon } from'../components/addon3/third.addon';
@NgModule({
declarations: [
MyApp,
MyFirstAddon, <--- Working well
MySecondAddon,
MyThirdAddon
],
Create a feature module that exports your components and directives
Add that module to imports of other modules where you want to use your addons