Reputation: 8166
I am trying to display translated list in PrimeNG dropdown.
HTML :
<p-dropdown [options]="companyProfileCategories" [(ngModel)]="CompanyCategoryId" [style]="{'width':'150px'}">
<ng-template let-car pTemplate="item">
<div class="ui-helper-clearfix" style="position: relative;height: 25px;">
<div style="font-size:14px;margin-top:4px;color:white;">{{car.Name|json}}</div>
</div>
</ng-template>
</p-dropdown>
This is getting me data in console element like following :
But the dropdown is still not displayed. Check Image.
I have tried changing CSS and other styles.
Array Data :
companyProfileCategories = [{
"ID": "SomeID",
"Name": "ad_media"
}, {
"ID": "SomeID2",
"Name": "photos"
}]
Upvotes: 0
Views: 2826
Reputation: 1429
According to documentation (https://www.primefaces.org/primeng/#/dropdown), the [options]
array should be a SelectItem
array, so it must have two required fields that are label
and value
, where value
is the value of the dropdown and label
is the displayed string. Your array should be like:
companyProfileCategories = [{
"value": "SomeID",
"label": "ad_media"
}, {
"value": "SomeID2",
"label": "photos"
}]
Upvotes: 2