Popover气泡

在点击控件或者某个区域后,浮出一个气泡菜单来做更多的操作。如果设置了遮罩层,建议通过点击遮罩层的任一位置,进行退出。

代码演示

气泡

  1. import { Component } from '@angular/core';
  2. @Component({
  3. selector: 'demo-popover-basic',
  4. template: `
  5. <Navbar [leftContent]="'Back'"
  6. [mode]="'light'"
  7. [rightContent]="popover"
  8. (onLeftClick)="onLeftClick()"
  9. >NavBar</Navbar>
  10. <ng-template #popover>
  11. <Icon Popover
  12. [ngStyle]="{'height': '100%', 'display': 'flex', 'align-items': 'center'}"
  13. [mask]="true"
  14. [showArrow]="true"
  15. [overlay]="overlay"
  16. [type]="'ellipsis'"
  17. [placement]="'bottomRight'"
  18. (onSelect)="onSelect($event)"
  19. (onVisibleChange)="onVisibleChange($event)"
  20. ></Icon>
  21. </ng-template>
  22. <ng-template #overlay>
  23. <PopoverItem [icon]="icon1">Scan</PopoverItem>
  24. <PopoverItem [icon]="icon2" [ngStyle]="{'whiteSpace': 'nowrap'}">My Qrcode</PopoverItem>
  25. <PopoverItem [icon]="icon3">
  26. <span [ngStyle]="{'marginRight': 5}">Help</span>
  27. </PopoverItem>
  28. </ng-template>
  29. <ng-template #icon1>
  30. <Icon [src]="'https://gw.alipayobjects.com/zos/rmsportal/tOtXhkIWzwotgGSeptou.svg'" [size]="'xs'"></Icon>
  31. </ng-template>
  32. <ng-template #icon2>
  33. <Icon [src]="'https://gw.alipayobjects.com/zos/rmsportal/PKAgAqZWJVNwKsAJSmXd.svg'" [size]="'xs'"></Icon>
  34. </ng-template>
  35. <ng-template #icon3>
  36. <Icon [src]="'https://gw.alipayobjects.com/zos/rmsportal/uQIYTFeRrjPELImDRrPt.svg'" [size]="'xs'"></Icon>
  37. </ng-template>
  38. `
  39. })
  40. export class DemoPopoverBasicComponent {
  41. state = {
  42. selected: ''
  43. };
  44. constructor() {}
  45. onSelect(event) {
  46. console.log(event);
  47. }
  48. onVisibleChange(event) {
  49. console.log(event);
  50. }
  51. onLeftClick() {
  52. console.log('onLeftClick');
  53. }
  54. }

Popover 气泡 - 图1

API

Popover

属性说明类型默认值
visible当前显隐状态Booleanfalse
onVisibleChange当显隐状态变化时回调函数(visible: bool): void-
placementenum{'left','right','top','bottom', 'topLeft', 'topRight', 'bottomLeft', 'bottomRight'}String'bottomRight'
mask是否显示遮罩背景层Booleanfalse
overlay弹出层内容TemplateRef-
onSelect选中某选项时的回调函数(node: any, index?: number): void-
className传入自定义class, e.g. "am-popover-${your className}"stringam-popover
autoClose是否使用点击popover元素关闭popoverBooleantrue

Popover.Item

属性说明类型默认值
disabled是否禁用Booleanfalse
styleitem 样式Object-
iconiconTemplateRef-