Questions tagged [angularjs-track-by]
51 questions
167
votes
8 answers
How to use `trackBy` with `ngFor`
I can't really understand what I should return from trackBy. Based on some examples I've seen on the web, I should return the value of some property on the object. Is it right? Why should I get index as a parameter?
For example, in the following…

Max Koretskyi
- 101,079
- 60
- 333
- 488
58
votes
5 answers
how to use track by inside ngFor angular 2
tried every syntax i can guess couldnt make it works !
{{post|json}}

Zalaboza
- 8,899
- 16
- 77
- 142
25
votes
4 answers
What is "track by" in AngularJS and how does it work?
I don't really understand how track by works and what it does.
My main goal is to use it with ng-repeat to add some precision.

N.K
- 1,601
- 2
- 19
- 31
24
votes
3 answers
ng-repeat with track by over multiple properties
I have a problem with angular ng-repeat directive.
Currently I work on some project where from the API I get a list of items (some times it could be 1k items) and this list should be refreshed every 5 seconds (it is monitoring related project).
When…

qwetty
- 1,238
- 2
- 10
- 24
9
votes
2 answers
8
votes
1 answer
Angular 4 - Reactive Forms - select item in a list from object not referenced in this list - trackby issue?
I am converting Angular 1.6 code to Angular 4 and I have an issue with a list of elements.
The code in Angular 1.6 is:
7
votes
1 answer
Angular - What is the point of implementing trackBy?
Since recently, the Angular styleguide-lint-extender "Codelyzer" is throwing warnings when you do not have a trackBy-function implemented on every *ngFor. I am wondering why this is considered an issue at all.
In this blog the example of…

Phil
- 7,065
- 8
- 49
- 91
5
votes
1 answer
Angular trackBy not working in nested *ngFor
My component is some what like

Shubham Sharma
- 315
- 2
- 18
5
votes
2 answers
ngFor trackBy function with custom parameters
The trackBy function (e.g. in an ngFor) provides two arguments: index and item (from the collection being iterated over). Is there a way to pass additional information (as parameters?) to th trackBy function?
My case is that I might be iterating…

skeej
- 840
- 1
- 8
- 23
4
votes
1 answer
What is the purpose of "track by" on "ng-options"
What is the purpose of the trackexpr (track by) in ng-options when using Angular 1.3?
In Angular 1.2, this expression changed the value="" expressions on the generated options to match the result of trackexpr on each item in the collection. This is…

Josh G
- 14,068
- 7
- 62
- 74
3
votes
2 answers
sorting an *ngFor array with trackBy in Angular 4
i'm having trouble sorting and array that has a trackBy function. The use case is as follows:
I have an item array. All these items have a z-index property. I also have a layer manager that can edit the z-index of each item. When I want to save my…

Martijn van den Bergh
- 1,434
- 1
- 20
- 40
3
votes
1 answer
ngFor trackBy stil re-rendering DOM?
I activated trackBy in my ngFor and i confirmed that it is called and working, but I still notice the DOM is re-rendered in my browser which cause the rows to flicker. What is happening here? In Angular1 I can see in my browser/chrome debugger that…

jonassvensson
- 491
- 1
- 6
- 11
2
votes
2 answers
Ng-repeat one-time binding and "track by" change
Our web app uses ngRepeat to display a list of items. The array and its objects are never changed, but values of the objects inside can be modified by the user.
We generate a unique trackId's for each item. This trackId is updated every time the…

Steve Fisher
- 41
- 3
2
votes
2 answers
ngRepeat track by: How to add event hook on model change?
I have a simple ngRepeat like the following:
arrayOfRecords is updated from a server and may contain new data.
ngRepeat's track by…

user193130
- 8,009
- 4
- 36
- 64
2
votes
1 answer
Updating array used by ng-options, refresh selected object
In angular the use of Track by to track selection by value instead of by reference is a nice feature if needed. But lets say I switch the array behind and the selected object id matches a new Id I want the select to change as well
How do I force it…

Ingó Vals
- 4,788
- 14
- 65
- 113