Skip to content

Instantly share code, notes, and snippets.

@htammen
Last active July 17, 2019 13:32
Show Gist options
  • Save htammen/2b10f3c7c907ac4096b0683e49435a8d to your computer and use it in GitHub Desktop.
Save htammen/2b10f3c7c907ac4096b0683e49435a8d to your computer and use it in GitHub Desktop.
MainController.ts (Typescript version of UI5 view controller that inherits from a BaseController)
sap.ui.define([
"de/tammenit/ui5/AppAdminApp/controller/BaseController",
"sap/ui/model/json/JSONModel",
"sap/ui/core/format/DateFormat",
"sap/ui/core/Fragment"
], function (BaseController: typeof de.tammenit.ui5.AppAdminApp.controller.BaseController,
JSONModel: typeof sap.ui.model.json.JSONModel,
DateFormat: typeof sap.ui.core.format.DateFormat,
Fragment: typeof sap.ui.core.Fragment
) {
"use strict";
enum LinkTargets {
HOMEPAGE = "homepage"
}
class Main extends BaseController {
//return Controller.extend("de.hessen.hzd.service_hessen.service_hessen.controller.Main", {});
constructor() {
// it's important to call the extend method here. It creates metadata that is used in UI5 apps via
// the method getMetadata. Hence we also assign this method to the prototype of our class.
let fnClass = BaseController.extend("de.tammenit.ui5.AppAdminApp.controller.Main", {});
Main.prototype.getMetadata = fnClass.prototype.getMetadata;
super("de.tammenit.ui5.AppAdminApp.controller.Main");
}
public onInit(): void {
this.getView().setModel(new JSONModel({
}, false), "viewModel")
// @ts-ignore
this.getView().setModel(this.getOwnerComponent().getMainModel())
}
}
return Main;
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment