Компоненты PrimeNG
Overlaypanel

Всплывающая панель

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

Свойства

NameTypeDefaultDescription
dismissablebooleantrueEnables to hide the overlay when outside is clicked.
showCloseIconbooleanfalseWhen enabled, displays a close icon at top right corner.
ariaCloseLabelstringcloseAria label of the close icon.
stylestringnullInline style of the component.
styleClassstringnullStyle class of the component.
appendToanynullTarget 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).
baseZIndexnumber0Base zIndex value to use in layering.
autoZIndexbooleantrueWhether to automatically manage layering.
showTransitionOptionsstring.12s cubic-bezier(0, 0, 0.2, 1)Transition options of the show animation.
hideTransitionOptionsstring.1s linearTransition options of the hide animation.
focusOnShowbooleantrueWhen enabled, first button receives focus on show.

События

NameParametersDescription
onShow-Callback to invoke when an overlay becomes visible.
onHide-Callback to invoke after overlay gets hidden.

Методы

NameParametersDescription
toggleevent: browser event<br>target?: target element to align the panel, defaults to event.targetToggles the visibility of the panel.
showevent: browser event<br>target?: target element to align the panel toDisplays the panel.
hide-Hides the panel.

Шаблоны

NameParameters
content-

Стилизация

NameElement
p-overlaypanelContainer element.
p-overlaypanel-contentContent of the panel.
p-overlaypanel-closeClose icon.