Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmetcetin01140 committed Jun 7, 2024
1 parent 390aac9 commit 15c7614
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/app/components/dropdown/dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ export class DropdownItem {
[attr.required]="required"
>
<ng-container *ngIf="!selectedItemTemplate; else defaultPlaceholder">{{ label() === 'p-emptylabel' ? '&nbsp;' : label() }}</ng-container>
<ng-container *ngIf="selectedItemTemplate && (selectedOption || selectedOption === 0)" [ngTemplateOutlet]="selectedItemTemplate" [ngTemplateOutletContext]="{ $implicit: selectedOption }"></ng-container>
<ng-container *ngIf="selectedItemTemplate && !isSelectedOptionEmpty()" [ngTemplateOutlet]="selectedItemTemplate" [ngTemplateOutletContext]="{ $implicit: selectedOption }"></ng-container>
<ng-template #defaultPlaceholder>
<span *ngIf="selectedOption === undefined">{{ label() === 'p-emptylabel' ? '&nbsp;' : label() }}</span>
<span *ngIf="isSelectedOptionEmpty()">{{ label() === 'p-emptylabel' ? '&nbsp;' : label() }}</span>
</ng-template>
</span>
<input
Expand Down Expand Up @@ -1205,6 +1205,10 @@ export class Dropdown implements OnInit, AfterViewInit, AfterContentInit, AfterV
return this.autoDisplayFirst && !this.placeholder() && (this.modelValue() === undefined || this.modelValue() === null) && !this.editable && this.options && this.options.length;
}

isSelectedOptionEmpty() {
return ObjectUtils.isEmpty(this.selectedOption);
}

isSelected(option) {
return this.isValidOption(option) && this.isOptionValueEqualsModelValue(option);
}
Expand Down

0 comments on commit 15c7614

Please sign in to comment.