Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70440

[ionic-4] Why is a function in *ngFor called multiple times?

$
0
0

@IonicGeoff wrote:

This happens in all versions of Ionic, and probably also in Angular, but can someone please explain why calling a function within an *ngFor loop calls the function many, many times more than expected i.e. once??

    <div *ngFor="let section of pageSections">
        <app-get-email *ngIf="section.type==email" [headertext]=getSignupHeader(section.pageContent)></app-get-email>
      </div>
    </div>

In this example there are only 5 pageSections, and only 1 section.type==email, yet the getSignupHeader() funtion is called more than 20 times!

Why is this??

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 70440

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>