Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8451

When to use curly bracket in data binding?

$
0
0

In the demo kit of openui5, the section Element Binding involves two forms of data binding implementation.

 

As in the code below:

 

var oMatrixLayout = new sap.ui.commons.layout.MatrixLayout();
oMatrixLayout.bindElement("/company");
oMatrixLayout.createRow(
 new sap.ui.commons.Label({text: "Name:"}),
 new sap.ui.commons.TextField({value: "{name}"}));
oMatrixLayout.createRow(
 new sap.ui.commons.Label({text: "Revenue:"}),
 new sap.ui.commons.TextField({value: "{revenue}"}));
oMatrixLayout.createRow(
 new sap.ui.commons.Label({text: "Employees:"}),
 new sap.ui.commons.TextField({value: "{employees}"}));

When specifying the values for text fields, we use curly brackets({}) to indicate the value is from the model. However, in the code that immediately follows this one, no curly brackets are used:

var data = {clients:[{firstName:"Donald", lastName:"Duck"}]};...// create and set model herevar oLabel = new sap.ui.commons.Label("myLabel");
oLabel.bindProperty("text", "firstName");
oLabel.bindElement("/clients/0");

As you can see, no curly brackets are used in oLabel.bindProperty("text", "firstName");

So, what's the difference between the two examples? When to use curly brackets in data binding and when not?


Viewing all articles
Browse latest Browse all 8451

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>