Skip to content

Commit

Permalink
fix(module: popover): fix visible input not use without init (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
Guoyuanqiang authored and 3fuyu committed Nov 29, 2018
1 parent e362320 commit 05313a4
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions components/popover/popover.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {
Renderer2,
TemplateRef,
ComponentFactory,
AfterViewInit
OnChanges,
SimpleChanges
} from '@angular/core';
import { PopoverComponent } from './popover.component';
import { PopoverOptions } from './popover-options.provider';
Expand All @@ -25,7 +26,7 @@ import * as Positioning from '../core/util/position';
selector: '[Popover], [nzm-popover]',
providers: [PopoverOptions]
})
export class PopoverDirective implements OnInit, AfterViewInit, OnDestroy {
export class PopoverDirective implements OnInit, OnChanges, OnDestroy {
popover: ComponentRef<PopoverComponent>;

private _eventListeners: Array<() => void> = [];
Expand Down Expand Up @@ -90,14 +91,16 @@ export class PopoverDirective implements OnInit, AfterViewInit, OnDestroy {
}
}

ngOnInit(): void {
ngOnInit(): void {}

}

ngAfterViewInit() {
if (this.visible) {
ngOnChanges(changes: SimpleChanges) {
if (changes.visible && changes.visible.currentValue) {
setTimeout(() => {
this.showPopover();
this.showPopover();
}, 0);
} else {
setTimeout(() => {
this.hidePopover();
}, 0);
}
}
Expand Down

0 comments on commit 05313a4

Please sign in to comment.