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

selectButton: Conditional template rendering is not working #13053

Closed
itismohammadreza opened this issue May 17, 2023 · 2 comments · Fixed by #13174
Closed

selectButton: Conditional template rendering is not working #13053

itismohammadreza opened this issue May 17, 2023 · 2 comments · Fixed by #13174
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@itismohammadreza
Copy link
Contributor

itismohammadreza commented May 17, 2023

Describe the bug

In some case I have a usage like this :

    <p-selectButton [(ngModel)]="value" [options]="options">
      <ng-template let-item *ngIf="condition">
        // some stuff
      </ng-template>
    </p-selectButton>

and I want to show template if the condition is true and use the default template if it is false.
Its behavior is that if condition = false it still uses the template in the code above.
other components like dropdown etc. have this feature properly for using TemplateDirective, but selectButton don't use it and cause this issue.

Reproducer

https://stackblitz.com/edit/github-wrgned?file=src%2Fapp%2Fapp.component.html,src%2Fapp%2Fapp.component.ts

Angular version

16.0.1

PrimeNG version

16.0.0

@itismohammadreza itismohammadreza added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label May 17, 2023
volvachev added a commit to volvachev/primeng that referenced this issue Jun 12, 2023
@cetincakiroglu cetincakiroglu added this to the 16.0.1 milestone Jun 16, 2023
@cetincakiroglu cetincakiroglu added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Jun 16, 2023
@payisesp
Copy link

payisesp commented Jul 7, 2023

This issue is back in the prime ng version 16.0.2

@mcOcin
Copy link

mcOcin commented Oct 5, 2023

I got a similar bug when I migrated from primeng 15 to 16.

I had to add 'pTemplate' attribute on the 'ng-template' to fix, like this:

<p-selectButton [options]="actionScopeOptions"
                         optionLabel="label"
                         optionValue="value"
                         [optionDisabled]="'SELECTION'"
                         [(ngModel)]="selectedActionScope">
          <ng-template let-item pTemplate>
             <ng-container *ngIf="item.value === 'ALL'; then allButton; else selectionButton"></ng-container>
             <ng-template #allButton>
               <span>{{item.labelI18NKey | translate : {nombre: rechercheTotalCount} }}</span>
             </ng-template>
             <ng-template #selectionButton>
               <span>{{item.labelI18NKey | translate : {nombre: (docListStore.selectedDocs$ | async)?.length} }}</span>
             </ng-template>
           </ng-template>
         </p-selectButton> 

I don't know why, would be great to get an explanation :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants