How can I implement the if / else condition in an XML representation in SapUI5 that uses the flag (condition) from JSONModel?
So far I have a Controller :
sap.ui.define([ "sap/ui/core/mvc/Controller", "sap/ui/model/json/JSONModel" ], function (Controller, JSONModel) { "use strict"; return Controller.extend("sap.ui.demo.myApp.myController", { onInit: function () { //// set data model on view var oData = { title: "A cool title", values: [{name: "Text 1", marketed: true}, {name: "Text 2", marketed: false}, {name: "Text 3", , marketed: true}] }; var oModel = new JSONModel(oData); this.getView().setModel(oModel); } }); });
and View :
<mvc:View controllerName="sap.ui.demo.myApp.myController" xmlns="sap.m" > <Panel expandable="true" expanded="true" headerText="{/title}" width="100%" content="{/values}"> <content> <Label text="{name}"/> </content> </Panel> </mvc:View>
Edit
Is there a better way to do this than to implement an over-quality XML preprocessor?
source share