Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to get parent's property in xml #7

Closed
terreb opened this issue Nov 7, 2016 · 5 comments
Closed

unable to get parent's property in xml #7

terreb opened this issue Nov 7, 2016 · 5 comments

Comments

@terreb
Copy link

terreb commented Nov 7, 2016

nativescript 2.3.0
tns-core-modules 2.3.0
tns-ios 2.3.0
nativescript-carousel-view 2.0.1
simulator iOS 9.3

How to reproduce:

  1. add this to slider-view.xml in the demo app:
    <Label text="{{ $parents['CarouselView'].position, $parents['CarouselView'].position }}" />
  1. run the demo
@alexrainman
Copy link
Owner

@terreb i don't if you can access to $parents from a view loaded with builder. I will do my tests later on and let you know. Thanks

@alexrainman
Copy link
Owner

You can follow this NativeScript/NativeScript#3077

@alexrainman
Copy link
Owner

{N} Team provided an example for this that i will be testing. Thanks

@alexrainman
Copy link
Owner

It seems that $parents doesn't provide access to the native widget properties but it's binding context instead, so if you want to access the CarouselView properties, you have to expose them in the ViewModel like this:

get position(): number {
   var page = frame.topmost().currentPage;
    var slider = <CarouselView>page.getViewById("carouselView");
    return slider.position;
}

@terreb
Copy link
Author

terreb commented Nov 25, 2016

ok, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants