Closed anaszgh closed 6 years ago
It returns undefined!
this it my markup
`
<slide class="slide-2">
<image src="~/images/intro_img_2.png"></image>
<Label text="Title"></Label>
<TextView text="this is a short paragraph this is a short paragraph this is a short paragraph this is a short paragraph "></TextView>
<button text="Next" ></button>
</slide>
<slide class="slide-3">
<image src="~/images/intro_img_3.png"></image>
<Label text="Title"></Label>
<TextView text="this is a short paragraph this is a short paragraph this is a short paragraph this is a short paragraph "></TextView>
<button text="Next" ></button>
</slide>
</slides>
`
and this it the TS initialization that results in undefined
@ViewChild("slides") slides: ElementRef;
public ngAfterViewInit(){ console.log(this.slides); }
@anaszgh you nedd to add a querySelector to the slides component .
<slides #slides .....
Hope that helps
Hi @anaszgh, you will need to used angular's
ViewChild
decorator to get the element. you can then access all the public functions on it.Here is a stack overflow post I commented on that uses a StackLayout. It' the same idea. https://stackoverflow.com/questions/37884142/in-nativescript-with-angular2-how-can-i-get-an-interface-element-the-id/37884606#37884606