8000 trackBy in *ngFor not working in <select>? · Issue #13828 · angular/angular · GitHub
[go: up one dir, main page]

Skip to content

trackBy in *ngFor not working in <select>? #13828

New issue

Have a question about this project? Sign u 8000 p for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
doender opened this issue Jan 7, 2017 · 4 comments
Closed

trackBy in *ngFor not working in <select>? #13828

doender opened this issue Jan 7, 2017 · 4 comments

Comments

@doender
Copy link
doender commented Jan 7, 2017

I'm submitting a ...

[x] bug report => search github for a similar issue or PR before submitting

Current behavior
When using ngModel and trackBy in <select> the initial value is not selected when it is an object.

Expected behavior
Initial value should be selected.

Minimal reproduction of the problem with instructions
HTML:

<select [(ngModel)]="selectedItem">
    <option *ngFor="let item of items; trackBy:itemIdentity" [value]="item">
      {{item.name}}
   </option>
</select>

TS:

private items = [{id: 0, name: 'first'}, {id: 1, name: 'second'}];
private selectedItem = {id: 1, name: 'second'};

itemIdentity(index:number, item:any):any {
   return item.id;
}
  • Angular version: 2.4.1
  • Browser: Chrome
  • Language: TypeScript X.X
@DzmitryShylovich
Copy link
Contributor
DzmitryShylovich commented Jan 7, 2017

Select doesn't use trackBy function from ngFor for comparing options.
Duplicate of #13268

@DzmitryShylovich
Copy link
Contributor

@pkozlowski-opensource was fixed here #13349

@pkozlowski-opensource
Copy link
Member

Fixed via f89d004, thnx @DzmitryShylovich

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants
0