Custom block creation


#1

Hi,

I haven’t found a styleguide for ionic 2 si i wanted to ask what is the prefered way of doing something like this:

   <div class="bottom-nav" (click)="goToMain()">
       <ion-icon ios="ios-arrow-back"></ion-icon><span>Main page</span>
   </div>

I’m having this button like on every page except the home which when is clicked fires function which return me to home page.
So im’m guesing this should be some custom component not a page.
Question is where should i put files for this component which will then be included inside every page except the home page?

Thanks in advance!


#2

I resolved this by myself,

  @Component({
    selector: 'back-to-main',
    template: `
         <div class="bottom-nav" (click)="goToMain()">
            <ion-icon ios="ios-arrow-back" md="md-arrow-back"></ion-icon><span>Main page</span>
        </div>
   `
})

export class ReturnHome {
    constructor(public navCtrl: NavController) {}

    goToMain(){
        this.navCtrl.push(HomePage);
    }
}`

i created my own component,export that class and than imported it inside app.module.ts,and than put it inside declarations array and entryComponents array.Hope this is clean solution :slight_smile: