Reputation: 76
I want to present a toast message to the user with his first name that I have in a variable. Is it possible? If so, how?
I want to do something like that:
this.toastCtrl.create({
message: "Welcome user.firstname" ,
duration: 3000
}).present();
where user.firstname
contains my user's firstname.
PS: The code above is not working, it shows the message "Welcome user.firstname"
Upvotes: 2
Views: 1308
Reputation: 2600
Simply do:
this.toastCtrl.create(
{
message: "Welcome " + user.firstname,
duration: 3000
}
).present();
Upvotes: 1
Reputation: 3868
You can add parameters to the toast
async toastCtrl(msg) {
const toast = await this.toastController.create({
message: msg,
duration: 300
});
toast.present();
}
Call the function with a variable
this.toastCtrl('Welcome ' + user.firstname);
Upvotes: 1