Questions tagged [angularjs-track-by]

49 questions
2
votes
1 answer

Angular: What do you do when you need to 'track by' but you don't have a unique property to track by?

Say that I'm ng-repeating over images, which is an array of objects that have a src and a caption property. var images = [ {src: 'a.jpg', caption: 'a'}, {src: 'b.jpg', caption: 'b'}, {src: 'c.jpg', caption: 'c'}, {src: 'd.jpg', caption:…
Adam Zerner
  • 12,221
  • 13
  • 62
  • 128
1
vote
0 answers

Angularjs When to use track-by over select-as in ng-options directive

I would like to know in which situations is recommended to use track by over select as in ng-options directive? Here we have the two options: I reset the list $scope.reset = function () { $scope.search =…
Interlated
  • 2,849
  • 1
  • 34
  • 57
1
vote
1 answer

ng-init is not calling second time when track by $index used

html:
{{employeeName}}
1
vote
2 answers

ng-repeat track by $index not working with pagination

I'm working with ng-repeat + Filter + Pagination(ui-bootstrap) 1- ng-repeat + filter is working fine : 2- ng-repeat + filter + pagination is working fine too:
Inoubli
  • 246
  • 2
  • 9
1
vote
1 answer

Where to add 'track by $index' when using Filter and Pagination in the same ng-repeat

I have my ng-repeat and filter ,then I added bootstrap-ui pagination and everything working fine To add fields Edit, I needed to use 'track by $index' but I cant find the correct way to add it to my ng-repeat, This is my HTML view :
Inoubli
  • 246
  • 2
  • 9
1
vote
2 answers

angular material md-select using track by but still getting $$hashKey

I'm trying to get rid of the $$hashKey value that angular adds to your model value. According to most sources implementing a track by should solve this issue but I'm doing something wrong. The vm.productTypes is any array of objects with id…
Tersius
  • 217
  • 4
  • 17
1
vote
1 answer

General angular ng-repeat and track by $index

Just a general question about using track by $index in an ng-repeat, I couldn't find a solution in the docs... I have a
{{concert}}
, below it, I have an array, that is dynamically populated…
1
vote
1 answer

How to resolve angular ng-options track by deep clone issue?

ng-options="branch as branch.name for branch in ordersItemClientInfo.branches track by branch.id" In my case "branches" is an array of object and each of them have field ref to so deep object (map geoObject). Angular tries to copy thats object and…
nitro-n
  • 333
  • 1
  • 3
  • 9
1
vote
1 answer

Angular ng-options with track by creates unknown option element

My goal here is to generate a select list that has the option values set to one of my objects properties. When adding the track by binding option to the ng-options directive an unknown option element is created and it is the only option that ever…
HisDivineShadow
  • 765
  • 1
  • 7
  • 16
1
vote
0 answers

ng-repeat track by with hashKey default

Question: Is it possible to define an ng-repeat track by expression which will use a particular attribute if it exists, but use the default $$hashKey behavior if that attribute is undefined? Context: I have a chat application which displays an array…
David
  • 315
  • 4
  • 11
0
votes
0 answers

Angular ngFor rerender trackBy when changing the array position

I want the ngFor not to re-render when the id change the index/position on the array. The trackBy method not working as I expected in this situation. Consider code below, In the TS File users: User[]; constructor() { this.change1(); } …
oz1985oz
  • 229
  • 1
  • 5
0
votes
1 answer

Angular trackBy giving Missing Properties Error

I am using track by function in my ionic angular app and while building the app, it gives me error: Type '(index: any, item: any) => any' is missing the following properties from type 'any[]': pop, push, concat, join, and 25 more. I am using this…
0
votes
0 answers

Angular trackBy using index on nested forms

If i have a three level nested forms using *ngFor and dont have an unique id or field, can i use the index for every *ngFor in each trackBy function?