Set two button in single file and move one page to another page with different page


#1

Here i have add my code Please help me.

Home.html

<button ion-button color="btncolor" full (click)="doLogin()">Login</button>
<button ion-button color="btncolor" full (click)="doRegister()">Register</button>

Home.ts


import { RegistrationPage } from '../registration/registration';
import { MainHomedPage } from '../MainHome/mainhome';
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';


@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})

export class HomePage {


 constructor(public navCtrl: NavController) {


}

**doLogin(){**

this.navCtrl.push(MainHomedPage);


}
**doRegister()**{

     this.navCtrl.push(RegistrationPage);

}
}

#2

Hello

Please help me for the how to add two button on same html page and how to navigate on button click with different page.

Thanks


#5

The question is hard to understand, but perhaps these buttons are inside a <form> element, in which case unless they have the type="button" attribute they will both submit the form.


#6

If I understand your question, you are on a page of class HomePage and you want users to view a different form to Register or to Login. If so, there are many ways to handle this, but the easiest way is with [navPush].

In your HTML:

<button ion-button color="btncolor" full [navPush]="loginPage">Login</button>
<button ion-button color="btncolor" full [navPush]="registrationPage">Register</button>

In your TypeScript:

import { RegistrationPage } from '../registration/registration';
import { LoginPage } from '../login/login';
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})

export class HomePage {

  loginPage = LoginPage;
  registrationPage = RegistrationPage;

  constructor(public navCtrl: NavController) {
  }

}

Hope that answers your question!