Pass parameter with a button


#1

I need to pass a page heading to a second page by means of buttons.

(click)=“buttonClicked({title: ‘emergency’})”

I am a Grandpa newbie and I need help. How do i get this heading on second page.

Thankyou so much for helping me.


#2

Take a look at NavParams to pass the data along to the new page.


#3

It will depend on how your loading your pages, and what’s your navigation strategy.

let paramObj = { title: 'emergency' };
let page = 'pageString'; // If using lazy loading
//let page = pageObject; // If using traditional navigation
nav.push(page, paramObj); // classic
// nav.setRoot(page, paramObj); // if you require to reload your page and destroy the previous one

#4

On the buttonCliked() function

use NavController to Pass Data and retrieve it Through NavParams

buttonClicked(){

this.navCtrl.push(SecondPage, {
title: ‘Emergency’
});

}
Then on the Second page User NavParams to retrieve Like this in your Construct
declare Title
title: string;

this.title = this.navParams.get(‘title’);

then you can Use {{title}} on the view in your second page.