Fix undefined error

This commit is contained in:
Çetin 2022-08-29 10:15:46 +03:00
parent c8913a71eb
commit c48da30d1a
2 changed files with 7 additions and 3 deletions

View File

@ -1,3 +1,7 @@
interface InventoryStatus {
label: string;
value: string;
}
export interface Product { export interface Product {
id?: string; id?: string;
code?: string; code?: string;
@ -5,7 +9,7 @@ export interface Product {
description?: string; description?: string;
price?: number; price?: number;
quantity?: number; quantity?: number;
inventoryStatus?: any; inventoryStatus?: InventoryStatus;
category?: string; category?: string;
image?: string; image?: string;
rating?: number; rating?: number;

View File

@ -98,7 +98,7 @@
<label for="status">Inventory Status</label> <label for="status">Inventory Status</label>
<p-dropdown id="status" [options]="statuses" optionLabel="label" [(ngModel)]="product.inventoryStatus" placeholder="Select a Status"> <p-dropdown id="status" [options]="statuses" optionLabel="label" [(ngModel)]="product.inventoryStatus" placeholder="Select a Status">
<ng-template pTemplate="selectedItem"> <ng-template pTemplate="selectedItem">
<span *ngIf="product && product.inventoryStatus" [class]="'product-badge status-' + product.inventoryStatus.toLowerCase()">{{product.inventoryStatus}}</span> <span *ngIf="product && product.inventoryStatus" [class]="'product-badge status-' + product.inventoryStatus.value.toLowerCase()">{{product.inventoryStatus.value}}</span>
</ng-template> </ng-template>
<ng-template let-status pTemplate="status"> <ng-template let-status pTemplate="status">
<span [class]="'product-badge status-' + status.value.toLowerCase()">{{status.label}}</span> <span [class]="'product-badge status-' + status.value.toLowerCase()">{{status.label}}</span>