Всплывающая панель
PrimeNG/OverlayPanel (opens in a new tab)
Компонент контейнера, который может показываться над другими компонентами на странице.
С чего начать
Подключите модуль
import { OverlayPanelModule } from 'primeng/overlaypanel';
В .ts файле
import { Component, OnInit } from '@angular/core';
export interface Product {
id?: string;
code?: string;
name?: string;
description?: string;
price?: number;
quantity?: number;
inventoryStatus?: string;
category?: string;
image?: string;
rating?: number;
}
@Component({
selector: 'app-prime-overlaypanel',
templateUrl: './prime-overlaypanel.component.html',
styleUrls: ['./prime-overlaypanel.component.scss'],
})
export class PrimeOverlaypanelComponent implements OnInit {
products: Product[] = [];
selectedProduct: Product | null = null;
status: string[] = ['OUTOFSTOCK', 'INSTOCK', 'LOWSTOCK'];
productNames: string[] = [
'Bamboo Watch',
'Black Watch',
'Blue Band',
'Blue T-Shirt',
'Bracelet',
'Brown Purse',
'Chakra Bracelet',
'Galaxy Earrings',
'Game Controller',
'Gaming Set',
'Gold Phone Case',
'Green Earbuds',
'Green T-Shirt',
'Grey T-Shirt',
'Headphones',
'Light Green T-Shirt',
'Lime Band',
'Mini Speakers',
'Painted Phone Case',
'Pink Band',
'Pink Purse',
'Purple Band',
'Purple Gemstone Necklace',
'Purple T-Shirt',
'Shoes',
'Sneakers',
'Teal T-Shirt',
'Yellow Earbuds',
'Yoga Mat',
'Yoga Set',
];
constructor() { }
ngOnInit(): void {
this.products = [
{
id: '1000',
code: 'f230fh0g3',
name: 'Bamboo Watch',
description: 'Product Description',
image: 'bamboo-watch.jpg',
price: 65,
category: 'Accessories',
quantity: 24,
inventoryStatus: 'INSTOCK',
rating: 5
},
{
id: '1001',
code: 'nvklal433',
name: 'Black Watch',
description: 'Product Description',
image: 'black-watch.jpg',
price: 72,
category: 'Accessories',
quantity: 61,
inventoryStatus: 'INSTOCK',
rating: 4
},
{
id: '1002',
code: 'zz21cz3c1',
name: 'Blue Band',
description: 'Product Description',
image: 'blue-band.jpg',
price: 79,
category: 'Fitness',
quantity: 2,
inventoryStatus: 'LOWSTOCK',
rating: 3
},
{
id: '1003',
code: '244wgerg2',
name: 'Blue T-Shirt',
description: 'Product Description',
image: 'blue-t-shirt.jpg',
price: 29,
category: 'Clothing',
quantity: 25,
inventoryStatus: 'INSTOCK',
rating: 5
},
{
id: '1004',
code: 'h456wer53',
name: 'Bracelet',
description: 'Product Description',
image: 'bracelet.jpg',
price: 15,
category: 'Accessories',
quantity: 73,
inventoryStatus: 'INSTOCK',
rating: 4
},
{
id: '1005',
code: 'av2231fwg',
name: 'Brown Purse',
description: 'Product Description',
image: 'brown-purse.jpg',
price: 120,
category: 'Accessories',
quantity: 0,
inventoryStatus: 'OUTOFSTOCK',
rating: 4
},
{
id: '1006',
code: 'bib36pfvm',
name: 'Chakra Bracelet',
description: 'Product Description',
image: 'chakra-bracelet.jpg',
price: 32,
category: 'Accessories',
quantity: 5,
inventoryStatus: 'LOWSTOCK',
rating: 3
},
{
id: '1007',
code: 'mbvjkgip5',
name: 'Galaxy Earrings',
description: 'Product Description',
image: 'galaxy-earrings.jpg',
price: 34,
category: 'Accessories',
quantity: 23,
inventoryStatus: 'INSTOCK',
rating: 5
},
{
id: '1008',
code: 'vbb124btr',
name: 'Game Controller',
description: 'Product Description',
image: 'game-controller.jpg',
price: 99,
category: 'Electronics',
quantity: 2,
inventoryStatus: 'LOWSTOCK',
rating: 4
},
{
id: '1009',
code: 'cm230f032',
name: 'Gaming Set',
description: 'Product Description',
image: 'gaming-set.jpg',
price: 299,
category: 'Electronics',
quantity: 63,
inventoryStatus: 'INSTOCK',
rating: 3
}
];
}
}
Встройте компонент с помощью тэга p-overlayPanel.
OverlayPanel
Свойства
Name | Type | Default | Description |
---|---|---|---|
dismissable | boolean | true | Enables to hide the overlay when outside is clicked. |
showCloseIcon | boolean | false | When enabled, displays a close icon at top right corner. |
ariaCloseLabel | string | close | Aria label of the close icon. |
style | string | null | Inline style of the component. |
styleClass | string | null | Style class of the component. |
appendTo | any | null | Target element to attach the panel, valid values are "body" or a local ng-template variable of another element (note: use binding with brackets for template variables, e.g. [appendTo]="mydiv" for a div element having #mydiv as variable name). |
baseZIndex | number | 0 | Base zIndex value to use in layering. |
autoZIndex | boolean | true | Whether to automatically manage layering. |
showTransitionOptions | string | .12s cubic-bezier(0, 0, 0.2, 1) | Transition options of the show animation. |
hideTransitionOptions | string | .1s linear | Transition options of the hide animation. |
focusOnShow | boolean | true | When enabled, first button receives focus on show. |
События
Name | Parameters | Description |
---|---|---|
onShow | - | Callback to invoke when an overlay becomes visible. |
onHide | - | Callback to invoke after overlay gets hidden. |
Методы
Name | Parameters | Description |
---|---|---|
toggle | event: browser event<br>target?: target element to align the panel, defaults to event.target | Toggles the visibility of the panel. |
show | event: browser event<br>target?: target element to align the panel to | Displays the panel. |
hide | - | Hides the panel. |
Шаблоны
Name | Parameters |
---|---|
content | - |
Стилизация
Name | Element |
---|---|
p-overlaypanel | Container element. |
p-overlaypanel-content | Content of the panel. |
p-overlaypanel-close | Close icon. |