1

Trying to get right syntax for context binding in XML view. I have a JSON model and set the model to view with name "company" inside controller. When I use absolute path, it works but when I use relative path, it doesn't. It seems, view is unable to access the model in second case.

My Code

<Text text ="{company>/data/name}" width="200px"/>
<Input binding="{company>/data}" value ="{name}" width="200px"/>
Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
SQL_NOVICE
  • 35
  • 1
  • 7

1 Answers1

1

When binding a property, you also have to provide the name of the model. Otherwise the "nameless" default model is assumed. But since all your data is in the company model you have to explicitly state that name for your value.

<Input binding="{company>/data}" value="{company>name}" width="200px"/>
Marc
  • 6,051
  • 5
  • 26
  • 56
  • that works! Thank you very much. My expectation was, I do not need to mention the model name again , because I already did that in "binding". – SQL_NOVICE Dec 22 '18 at 20:03
  • @SQL_NOVICE Glad to hear it worked :) Please [accept this answer](https://stackoverflow.com/help/someone-answers) to let others know that this issue is resolved now. – Boghyon Hoffmann Dec 22 '18 at 22:05
  • 1
    @SQL_NOVICE the beauty of it is that you can use multiple models this way. For example you can do `value="{i18n>label.companyName} {company>name}"` and combine a translated value of your i18n file with the value of your json model. The binding just makes it easier to access a specific entry of your model. – Marc Dec 23 '18 at 22:20