Accessing visible template link inside template element?

How to select the item that is currently displayed

My attempt was like this:

app.component.html

 <ScrollView>
    <StackLayout>
      <StackLayout width="100%" *ngFor="let item of images$">
          <Image #image [src]="item.url" stretch="aspectFill" colSpan="3" row="0"></Image>
      </StackLayout>
    </StackLayout>
  </ScrollView>

      

app.component.ts

   @ViewChildren('image') image: QueryList<Image>;
   ngAfterViewInit(): void {
     this.image.changes.subscribe((changes) => {
       alert("current:" + this.image.toArray()[0]);
       alert("current:" + this.image.toArray()[0].src);
      }
     );
   }

      

It only announces once.

Basically, the goal is to trigger the API displayed with an image when scrolling to the position of the element in question.

+3
angular angular2-nativescript


source to share


No one has answered this question yet

Check out similar questions:

451
How do I select an element in a component template?
349
Binding select element to object in Angular
328
* ngIf and * ngFor for one element causing the error
42
Angular 2: Is it possible to access template reference variables from a component class?
five
Accessing a template template inside a template element
4
Angular 4: How to access an element inside an ng template
2
Accessing DOM Element with Template Reference Variables on Component
2
Get a reference to an element inside an ng template
1
How can I refer to an element inside an ng template?
0
Getting a link to a template inside ngFor



All Articles
Loading...
X
Show
Funny
Dev
Pics