*ngFor iterate function are called many times
See original GitHub issueI’m submitting a…
[ ] Regression (a behavior that used to work and stopped working in a new release)
[X] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
for example, if you have a function that debugs a list, it is called several times when, theoretically, it should only be called once.
Expected behavior
https://stackblitz.com/edit/angular-ymxjt6?file=app%2Fapp.component.ts
Like a list should work in the service To only be called once to instantiate it.
Minimal reproduction of the problem with instructions
https://stackblitz.com/edit/angular-ymxjt6?file=app%2Fapp.component.ts
What is the motivation / use case for changing the behavior?
Environment
Angular version: X.Y.Z
Angular CLI: 1.6.1
Node: 8.0.0
OS: win32 x64
Angular: 5.1.1
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router
@angular/cdk: 5.0.1
@angular/cli: 1.6.1
@angular/material: 5.0.1
@angular/service-worker: 5.1.2
@angular-devkit/build-optimizer: 0.0.36
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.42
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.1
@schematics/angular: 0.1.11
@schematics/schematics: 0.0.11
typescript: 2.4.2
webpack: 3.10.0
Browser:
- [x] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
For Tooling issues:
- Node version: XX
- Platform:
Others:
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Function on ngFor loop is called too many times - Stack Overflow
I have a checkbox component in a loop that makes a call to the controller to see if it's checked on initial load....
Read more >[ionic-4] Why is a function in *ngFor called multiple times?
... someone please explain why calling a function within an *ngFor loop calls the function many, many times more than expected i.e. once?...
Read more >Angular ngFor - Learn All Features, Not Only For Arrays
we are passing to ngFor an iteration expression; a loop variable named hero is defined using the keyword let , which is consistent...
Read more >NgFor • Angular - codecraft.tv
We use the NgFor directive to loop over an array of items and create multiple elements dynamically from a template element. The template...
Read more >How to repeat HTML element multiple times using ngFor ...
We can print repeated lines of content based on a number using the javascript/typescript function Array() which will generate a list of ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Phoenix404 Use
trackBy
and probably alsoOnPush
strategy.This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.