import { CommonModule } from '@angular/common'; import { Component } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { ButtonModule } from 'primeng/button'; import { DataViewModule } from 'primeng/dataview'; import { OrderListModule } from 'primeng/orderlist'; import { PickListModule } from 'primeng/picklist'; import { SelectButtonModule } from 'primeng/selectbutton'; import { TagModule } from 'primeng/tag'; import { Product, ProductService } from '@/app/pages/service/product.service'; @Component({ selector: 'app-list-demo', standalone: true, imports: [CommonModule, DataViewModule, FormsModule, SelectButtonModule, PickListModule, OrderListModule, TagModule, ButtonModule], template: `
DataView
{{ item.category }}
{{ item.name }}
{{ item.rating }}
$ {{ item.price }}
{{ item.category }}
{{ item.name }}
{{ item.rating }}
$ {{ item.price }}
PickList
{{ item.name }}
OrderList
{{ option.name }}
`, styles: ` ::ng-deep { .p-orderlist-list-container { width: 100%; } } `, providers: [ProductService] }) export class ListDemo { layout: 'list' | 'grid' = 'list'; options = ['list', 'grid']; products: Product[] = []; sourceCities: any[] = []; targetCities: any[] = []; orderCities: any[] = []; constructor(private productService: ProductService) {} ngOnInit() { this.productService.getProductsSmall().then((data) => (this.products = data.slice(0, 6))); this.sourceCities = [ { name: 'San Francisco', code: 'SF' }, { name: 'London', code: 'LDN' }, { name: 'Paris', code: 'PRS' }, { name: 'Istanbul', code: 'IST' }, { name: 'Berlin', code: 'BRL' }, { name: 'Barcelona', code: 'BRC' }, { name: 'Rome', code: 'RM' } ]; this.targetCities = []; this.orderCities = [ { name: 'San Francisco', code: 'SF' }, { name: 'London', code: 'LDN' }, { name: 'Paris', code: 'PRS' }, { name: 'Istanbul', code: 'IST' }, { name: 'Berlin', code: 'BRL' }, { name: 'Barcelona', code: 'BRC' }, { name: 'Rome', code: 'RM' } ]; } getSeverity(product: Product) { switch (product.inventoryStatus) { case 'INSTOCK': return 'success'; case 'LOWSTOCK': return 'warn'; case 'OUTOFSTOCK': return 'danger'; default: return 'info'; } } }