UNPKG

generator-stui5

Version:
37 lines (29 loc) 1.11 kB
sap.ui.define([ "sap/ui/core/UIComponent", "sap/ui/model/json/JSONModel", "sap/m/routing/RouteMatchedHandler" ], function (UIComponent, JSONModel, RouteMatchedHandler) { "use strict"; return UIComponent.extend("<%= appNamespace %>.Component", { metadata : { manifest : "json" }, init : function() { // TODO: how to load local json models from the model directory? // set device model var bIsPhone = sap.ui.Device.system.phone; var oDeviceModel = new JSONModel({ isPhone : bIsPhone, isNoPhone : !bIsPhone, listMode : bIsPhone ? "None" : "SingleSelectMaster", listItemType : bIsPhone ? "Active" : "Inactive" }); oDeviceModel.setDefaultBindingMode("OneWay"); this.setModel(oDeviceModel, "device"); // call the super init - calling this after models are declared makes models available in the onInit methods of controllers. Not sure why. Doesn't seem to work for i18n defined models sap.ui.core.UIComponent.prototype.init.apply(this, arguments); new sap.m.routing.RouteMatchedHandler(this.getRouter()); this.getRouter().initialize(); }, }); });