Single button with different information display

Hi I would need help on using a single button “More information” to display different information based on product ID using if else condition.

that’s really really simple.
suggestion nr 1, if you find this hard, read the angular fundamentals.

Somewhere in your code make a function like this:

let’s suppose you get the id value (is it user-id?) from your backend and that while entering this section you already have an id-value.

yourMessage: string = 'Default Value';
yourID: number = 3; //or just the value you need or you get from backend

ionViewWillEnter() {
   if(this.yourID == 1) {
    this.yourMessage = 'something';
   } else if(this.yourID == 2) {
          this.yourMessage = 'something else';
   }
} // do this for all your ids and don't forget to set a default case. If you have a lot of ids use a switch/case

...

then in your .html file just set the button like this

<ion-button color="primary">{{yourMessage}}</ion-button>

this will show a different

1 Like

Start here: Angular

2 Likes