Панель
PrimeNG/Panel (opens in a new tab)
Panel - это контейнер с дополнительной функцией переключения содержимого.
С чего начать
Подключите модуль
import { PanelModule } from 'primeng/panel';
Встройте компонент с помощью тэга p-slideMenu.
Regular
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Advanced
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
import { Component, OnInit } from '@angular/core';
import { MessageService } from 'primeng/api';
import { MenuItem } from 'primeng/api';
@Component({
selector: 'app-prime-panel',
templateUrl: './prime-panel.component.html',
styleUrls: ['./prime-panel.component.scss'],
providers: [MessageService],
})
export class PrimePanelComponent implements OnInit {
constructor(private messageService: MessageService) {}
items: MenuItem[] = [];
ngOnInit(): void {
this.items = [
{
label: 'Options',
items: [
{
label: 'Update',
icon: 'pi pi-refresh',
command: () => {
this.update();
},
},
{
label: 'Delete',
icon: 'pi pi-times',
command: () => {
this.delete();
},
},
],
},
{
label: 'Navigate',
items: [
{
label: 'Angular Website',
icon: 'pi pi-external-link',
url: 'http://angular.io',
},
{
label: 'Router',
icon: 'pi pi-upload',
routerLink: '/fileupload',
},
],
},
];
}
update() {
this.messageService.add({ severity: 'success', summary: 'Success', detail: 'Data Updated' });
}
delete() {
this.messageService.add({ severity: 'warn', summary: 'Delete', detail: 'Data Deleted' });
}
}
Свойства
Name | Type | Default | Description |
---|---|---|---|
header | string | null | Header text of the panel. |
toggleable | boolean | false | Defines if content of panel can be expanded and collapsed. |
collapsed | boolean | false | Defines the initial state of panel content, supports one or two-way binding as well. |
style | string | null | Inline style of the component. |
styleClass | string | null | Style class of the component. |
expandIcon | string | pi pi-plus | Expand icon of the toggle button. |
collapseIcon | string | pi pi-minus | Collapsed icon of the toggle button. |
showHeader | boolean | true | Specifies if header of panel cannot be displayed. |
transitionOptions | string | 400ms cubic-bezier(0.86, 0, 0.07, 1) | Transition options of the animation. |
toggler | string | icon | Specifies the toggler element to toggle the panel content, valid values are "icon" and "header". |
События
Name | Parameters | Description |
---|---|---|
onBeforeToggle | event.originalEvent: browser event<br>event.collapsed: state as a boolean | Callback to invoke before content toggle. |
onAfterToggle | event.originalEvent: browser event<br>event.collapsed: state as a boolean | Callback to invoke after content toggle. |
Шаблоны
Name | Parameters |
---|---|
header | - |
content | - |
icons | - |
footer | - |
Стилизация
Name | Element |
---|---|
p-panel | Container element. |
p-panel-titlebar | Header section. |
p-panel-title | Title text of panel. |
p-panel-titlebar-toggler | Toggle icon. |
p-panel-content | Content of panel. |