-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathApp.controller.ts
More file actions
20 lines (19 loc) · 877 Bytes
/
App.controller.ts
File metadata and controls
20 lines (19 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import MessageToast from "sap/m/MessageToast";
import Controller from "sap/ui/core/mvc/Controller";
import JSONModel from "sap/ui/model/json/JSONModel";
import ResourceModel from "sap/ui/model/resource/ResourceModel";
import ResourceBundle from "sap/base/i18n/ResourceBundle";
/**
* @name ui5.walkthrough.controller.App
*/
export default class AppController extends Controller {
onShowHello() : void {
// read msg from i18n model
// functions with generic return values require casting
const resourceBundle = (this.getView()?.getModel("i18n") as ResourceModel)?.getResourceBundle() as ResourceBundle;
const recipient = (this.getView()?.getModel() as JSONModel)?.getProperty("/recipient/name");
const msg = resourceBundle.getText("helloMsg", [recipient]) as string;
// show message
MessageToast.show(msg);
}
};