Skip to content
New issue

Have a question about this project? Sign up 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

Autocomplete -> nz-auto-optgroup -> dont work with new angular control flow (@for) #8412

Open
Lavos96 opened this issue Feb 20, 2024 · 4 comments

Comments

@Lavos96
Copy link

Lavos96 commented Feb 20, 2024

Reproduction link

https://stackblitz.com/edit/ng-zorro-antd-ivy-w1gcxk?file=src%2Fapp%2Fapp.component.ts

Steps to reproduce

Listing nz-autocomplete elements does not work if we use the new control-flow from Angular (i.e. @for syntax) and group options using nz-auto-optgroup tag. The old syntax works without problems (i.e. *ngFor)

What is expected?

New sytax will work.

What is actually happening?

New syntax dont work.

Environment Info
ng-zorro-antd 17.1.0
Browser Chrome 121.0.6167.185
@ParsaArvanehPA
Copy link
Contributor

Hi @Lavos96 ,
Your stackblitz link is broken; can you provide another one?

@Lavos96
Copy link
Author

Lavos96 commented Feb 26, 2024

@Nicoss54
Copy link
Collaborator

@Lavos96 after investigating a little bit, it seems it's not a problem with Ng Zorro itself

Here is your code with the older way

<nz-auto-option
							  *ngFor="let option of groups.groups"
								[nzLabel]="option.name"
								[nzValue]="option.id">
								{{ option.name }}
							</nz-auto-option>

if you want to migrate to new code flow syntax you should migrate like this

@for (option of groups.groups; track option.id) {
							<nz-auto-option
								[nzLabel]="option.name"
								[nzValue]="option.id">
								{{ option.name }}
							</nz-auto-option>
					}

if you do that you exemple work as expected

@Lavos96
Copy link
Author

Lavos96 commented Mar 1, 2024

@Nicoss54 after long investigation, it turned out that angularCompilerOptions -> preserveWhitespaces: true option in tsconfig.json is responsible for that. I was unable to reproduce that in stackblitz. There is an reported issue in angular repo for that: angular/angular#54077

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants