I created a small component which I want to use in some of the pages but I seem to have some problems when including it in more than one lazy load page.
add.button.component.ts
import { Component, Output, EventEmitter } from '@angular/core';
@Component({
selector: 'add-button',
template: `
<ion-buttons end>
<button ion-button icon-only (click)="navToAdd()">
<ion-icon name="md-add-circle"></ion-icon>
</button>
</ion-buttons>`
})
export class AddButton {
visible: boolean = true;
@Output() navigate: EventEmitter<any> = new EventEmitter();
navToAdd() {
this.navigate.emit(null)
}
}
app.modules.ts
import { BrowserModule } from '@angular/platform-browser';
import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import { TabsPage } from '../pages/tabs/tabs';
@NgModule({
declarations: [
MyApp,
HomePage,
TabsPage
],
imports: [
BrowserModule,
...
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
HomePage,
TabsPage
],
providers: [
...
]
})
export class AppModule { }
users.module.ts - Just like users.module.ts there are other page modules where I want to use the component just like i use it in users.module.ts below
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { UsersPage } from './users';
import { AddButton } from '../../components/add-button.component';
@NgModule({
declarations: [
UsersPage,
AddButton
],
imports: [
IonicPageModule.forChild(UsersPage),
],
})
export class UsersPageModule { }