Search code examples
javascriptxmlbindingsapui5

Expression Binding within Controller


Does anyone know if it's possible to use expression binding within javascript for example with the bindProperty method?

I would like to be able to use it like this:

new sap.m.Text().bindProperty("text", "= !${myModel>PropertyBoolean}")

All I found from SAP is the documentation for XML Views: help.sap.com


Solution

  • Expression binding was introduced for XMLViews to allow for some rudimentary coding (which is not possible with XML)

    In Javascript, this isn't needed of course. In your example, you could simply use a formatter function:

    new sap.m.Text().bindProperty("text", "myModel>PropertyBoolean", function(bValue) {
        return !bValue;
    });