<!DOCTYPE HTML>
<html style="height: 100%;">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Demo</title>
<script id="sap-ui-bootstrap"
src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js"
data-sap-ui-libs="sap.ui.core, sap.m"
data-sap-ui-theme="sap_belize"
data-sap-ui-oninit="module:sap/ui/core/ComponentSupport"
data-sap-ui-async="true"
data-sap-ui-compatVersion="edge"
data-sap-ui-resourceroots='{"demo": "./"}'
data-sap-ui-xx-componentPreload="off"
data-sap-ui-xx-waitForTheme="true"
></script>
</head>
<body id="content" class="sapUiBody">
<div data-sap-ui-component
data-id="rootComponentContainer"
data-name="demo"
data-height="100%"
data-settings='{"id": "rootComponent"}'
></div>
</body>
</html>
sap.ui.define([
"sap/ui/core/UIComponent",
"sap/ui/model/json/JSONModel",
], function(UIComponent, JSONModel) {
"use strict";
return UIComponent.extend("demo.Component", {
metadata: {
manifest: "json"
},
init: function() {
UIComponent.prototype.init.apply(this, arguments);
/**
* https://stackoverflow.com/q/55726017/5846045
*/
const oModelo = new JSONModel({
miSelectiona: "as",
});
this.setModel(oModelo, "miModelo");
//--------------------------------------
this.getRouter().initialize();
},
});
});
{
"_version": "1.14.0",
"start_url": "index.html",
"sap.app": {
"id": "demo",
"type": "application",
"title": "Demo",
"description": "Sample Code",
"applicationVersion": {
"version": "1.0.0"
},
"dataSources": {
"myDataSource": {
"type": "JSON",
"uri": "localData/demoData.json"
}
}
},
"sap.ui": {
"technology": "UI5",
"deviceTypes": {
"desktop": true,
"tablet": true,
"phone": true
},
"supportedThemes": [
"sap_belize_hcw",
"sap_belize_hcb",
"sap_belize",
"sap_belize_plus"
]
},
"sap.ui5": {
"dependencies": {
"minUI5Version": "1.52.0",
"libs": {
"sap.ui.core": {},
"sap.m": {}
}
},
"contentDensities": {
"compact": true,
"cozy": true
},
"resources": {
"js": [],
"css": []
},
"models": {
"": {
"dataSource": "myDataSource",
"preload": true
}
},
"rootView": {
"viewName": "demo.view.App",
"id": "rootView",
"type": "XML",
"async": true
},
"routing": {
"routes": [
{
"name": "home",
"pattern": "",
"target": "home",
"titleTarget": "home"
}
],
"targets": {
"home": {
"viewId": "homeView",
"viewName": "Home",
"transition": "fade",
"viewLevel": 1
},
"notFound": {
"viewId": "notFoundView",
"viewName": "Home",
"transition": "slide",
"viewLevel": 98
}
},
"config": {
"async": true,
"routerClass": "sap.m.routing.Router",
"viewType": "XML",
"viewPath": "demo.view",
"controlId": "rootApp",
"controlAggregation": "pages",
"transition": "slide",
"bypassed": {
"target": "notFound"
},
"homeRoute": "home"
}
}
}
}
<mvc:View
xmlns="sap.m"
xmlns:mvc="sap.ui.core.mvc"
controllerName="demo.controller.App"
displayBlock="true"
height="100%"
>
<App id="rootApp">
<pages>
<!-- will be added by Router -->
</pages>
</App>
</mvc:View>
<mvc:View
xmlns="sap.m"
xmlns:mvc="sap.ui.core.mvc"
controllerName="demo.controller.Home"
>
<Page id="homePage" title="Home">
<ObjectAttribute
title="miSelectiona"
text="{miModelo>/miSelectiona}"
/>
</Page>
</mvc:View>
sap.ui.define([
"sap/ui/core/mvc/Controller"
], function(Controller) {
"use strict";
return Controller.extend("demo.controller.App", {
onInit: function() {
},
});
});
sap.ui.define([
"sap/ui/core/mvc/Controller",
], function(Controller) {
"use strict";
return Controller.extend("demo.controller.Home", {
onInit: function() {
const oModelo = this.getOwnerComponent().getModel("miModelo");
alert(oModelo.getProperty("/miSelectiona"));
},
});
});
{
"collection": [],
"property": null
}