jlee
jlee

Reputation: 303

Ionic: How to add params to html [navPush]?

In a JS file I would write

navPush(page, {paramOne: "something"})

In html, in order to write a push, I'd write

[navPush]="modelPage"

How do I add params to the above, in html?

Upvotes: 0

Views: 1411

Answers (2)

Ömer
Ömer

Reputation: 188

To dynamically bind a single value you can use this code

<button ion-button [navPush]="NextPage" [navParams]="{color:[color]}">GO</button> // where color is a string variable 

On NextPage use this code

this.color = navParams.get('color');
console.log(this.color[0]);

Upvotes: 0

Mahesh Jadhav
Mahesh Jadhav

Reputation: 1089

You can pass parameters using the navParams property along with your navPush. It's use is mentioned in ionic official docs. you can use it in your html as:

<button ion-button [navPush]="pushPage" [navParams]="params">Go</button> // params is the object which you intend to pass to the page;

Upvotes: 1

Related Questions