Pass parameter with a button

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.

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

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

On the buttonCliked() function

use NavController to Pass Data and retrieve it Through NavParams


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.

1 Like