Data Binding Question


#1

I’m working with a ListView and want to pull data from outside the ListView’s source. I found the proper syntax to do it and got it working, but I want to get a better understanding of what’s happening.

You can look at an example I threw together in the Playground at https://play.nativescript.org/?template=play-js&id=de4Qwi&v=1

It works fine and throws no errors in the log.

If, however, you look at v2 of the project, it displays the value properly but throws an error on the Binding Property.

So … why does the Binding have to be repeated with the comma separator?
{{ $parents['ListView'].test, $parents['ListView'].test }} (as in v1)

Why doesn’t it work with one value?
{{ $parents['ListView'].test, $parents['ListView'].test }} (as in v2)


#2

And … a related followup question, which I haven’t made work yet.

If I want a conditional binding based on this, how do I do that? If, for instance, I want to set the class according to the value in the “test” variable?

class="{{ $parents['ListView'].test == 'hello' ? 'helloClass' : 'notHelloClass' }}"

I haven’t put this one into Playground but can do so if necessary.