是否有可能使用与toastController变量离子或角?

问题描述 投票:2回答:2

我想提出一个敬酒的消息与他的名字,我有一个变量的用户。可能吗?如果是这样,怎么样?

我想要做这样的事情:

this.toastCtrl.create({
  message: "Welcome user.firstname" ,
  duration: 3000
}).present();

其中user.firstname包含我的用户的姓名。

PS:上面的代码不工作,则显示消息“欢迎use​​r.firstname”

angularjs ionic-framework ionic3 toast
2个回答
1
投票

您可以添加参数来敬酒

async toastCtrl(msg) {
  const toast = await this.toastController.create({
    message: msg,
    duration: 300
    });
  toast.present();
}

调用函数的变量

this.toastCtrl('Welcome ' + user.firstname);

1
投票

简单地做:

this.toastCtrl.create(
    { 
        message: "Welcome " + user.firstname, 
        duration: 3000 
    }
).present();
© www.soinside.com 2019 - 2024. All rights reserved.