0
.TSのdoSomething(呼び出すときに.TSクラスを仮定メッセージプロパティを動的に渡してコントローラのsubTitleプロパティに警告する方法はありますか?
//imported everything
@Component({
selector: 'anything',
templateUrl: '.html',
})
export class anything{
public x: number;
let message : string;
constructor(public nav: NavController, public authData: AuthData,public service: Service) { }
async doSomething() {
try {
await this.authData.Something(this.x);
}
catch(error){
this.message = 'Sorry, sme error occured'
this.service.showAlert();
}
}
service.ts
//using alert controller code in this class.
showAlert(){
title: 'static',
subtitle: '', // need to add this message dynamically from the function that called the showAlert() function.
button: [Okay];
}
//code implemented.
)、それはcatchブロックでキャッチされた例外をスローとcatchブロックは、アラートコントローラのshowAlert()関数をトリガーします。
質問:showAlert()にsubTitleの値を動的に配置して、関数と呼ばれる関数に従ってメッセージを送信できるようにするにはどうすればよいですか?
注::構文エラーとタイプミスとインポートを無視してください。