Popover气泡

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

代码演示

气泡

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

Popover气泡 - 图1

API

Popover

参数说明类型默认值
[visible]当前显隐状态booleanfalse
[placement]气泡的位置‘left’ |’right’ |’top’ |’bottom’ | ‘topLeft’ | ‘topRight’ | ‘bottomLeft’ | ‘bottomRight’ | ‘bottomRight’
[mask]是否显示遮罩背景层booleanfalse
[overlay]弹出层内容TemplateRef-
[className]传入自定义class, e.g. “am-popover-${your className}”stringam-popover
[autoClose]是否使用点击popover元素关闭popoverbooleantrue
(onVisibleChange)当显隐状态变化时回调函数EventEmitter<boolean>-
(onSelect)选中某选项时的回调函数EventEmitter<node: any, index?: number>-

Popover.Item

参数说明类型默认值
disabled是否禁用booleanfalse
styleitem 样式object-
iconiconTemplateRef-