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 #16907

Closed
Alfonso2k opened this issue Dec 2, 2024 · 2 comments
Closed

Autocomplete #16907

Alfonso2k opened this issue Dec 2, 2024 · 2 comments
Assignees
Labels
Status: Pending Review Issue or pull request is being reviewed by Core Team
Milestone

Comments

@Alfonso2k
Copy link

Alfonso2k commented Dec 2, 2024

Autocomplete wont compile.

Hello, I have been trying to implement the autocomplete component with the source code provided but it wont compile because next line :
<ng-container *ngIf="!emptyTemplate; else empty"> {{ searchResultMessageText }} </ng-container> <ng-container #empty *ngTemplateOutlet="emptyTemplate"></ng-container>
Here, empty is undefined. What I am doing wrong? Thanks.

Environment

Development.

Reproducer

No response

Angular version

18.2.3

PrimeNG version

18.0.0

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

v20.18.0

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

No response

@Alfonso2k Alfonso2k added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Dec 2, 2024
@Alfonso2k Alfonso2k changed the title Component: Autocomplete Autocomplete Dec 2, 2024
@can-oezkan
Copy link
Contributor

can-oezkan commented Dec 2, 2024

You are probably referring to this in the source code:

<li *ngIf="!items || (items && items.length === 0 && showEmptyMessage)" class="p-autocomplete-empty-message" [ngStyle]="{ height: scrollerOptions.itemSize + 'px' }" role="option">
<ng-container *ngIf="!emptyTemplate; else empty">
{{ searchResultMessageText }}
</ng-container>
<ng-container #empty *ngTemplateOutlet="emptyTemplate"></ng-container>
</li>

I can't tell you why you're getting this error, but you could try using the new control flow syntax from angular. This is the version that uses the new control flow syntax:

<li *ngIf="!items || (items && items.length === 0 && showEmptyMessage)" class="p-autocomplete-empty-message" [ngStyle]="{ height: scrollerOptions.itemSize + 'px' }" role="option">
@if (!empty) {
{{ searchResultMessageText }}
} @else {
<ng-container *ngTemplateOutlet="empty"></ng-container>
}
</li>
(note that they renamed emptyTemplate to empty)

I Hope that this helps :)

@mertsincan mertsincan added Status: Pending Review Issue or pull request is being reviewed by Core Team and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Dec 4, 2024
@mertsincan mertsincan added this to the 18.0.0.Final milestone Dec 4, 2024
@mertsincan mertsincan removed their assignment Dec 5, 2024
cetincakiroglu added a commit that referenced this issue Dec 5, 2024
@cetincakiroglu
Copy link
Contributor

Hi,

Thanks a lot for testing the beta and reporting the issue. Issue is fixed in 1cff1d8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Pending Review Issue or pull request is being reviewed by Core Team
Projects
Status: Done
Development

No branches or pull requests

4 participants