Questions tagged [angularjs-track-by]

49 questions
77
votes
4 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
  • 85,840
  • 48
  • 270
  • 414
52
votes
4 answers

how to use track by inside ngFor angular 2

tried every syntax i can guess couldnt make it works ! {{post|json}}
Zalaboza
  • 8,143
  • 15
  • 64
  • 130
23
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.
xoxel
  • 1,390
  • 2
  • 15
  • 28
22
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,145
  • 1
  • 9
  • 23
9
votes
2 answers

Angular select and ng-options

I have this angular select:
Adrien
  • 307
  • 1
  • 4
  • 11
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
  • 5,442
  • 6
  • 36
  • 70
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
  • 802
  • 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
  • 13,566
  • 7
  • 55
  • 72
3
votes
1 answer

Angular trackBy not working in nested *ngFor

My component is some what like
Shubham Sharma
  • 235
  • 1
  • 15
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,146
  • 1
  • 14
  • 29
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
  • 481
  • 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…
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…
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,468
  • 14
  • 57
  • 108
1
2 3 4