Skip to content
This repository has been archived by the owner on Jan 6, 2022. It is now read-only.

Commit

Permalink
Add onContentInit output (closes #193)
Browse files Browse the repository at this point in the history
  • Loading branch information
arkon committed May 30, 2020
1 parent bb20a2e commit 054d5ce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ If you are using Angular's default emulated view encapsulation, you may have to

| Property name | Callback arguments | Description |
| ------------- | ------------------ | ----------- |
| onContentInit | | Corresponds with `ngAfterContentInit` lifecycle event of the sidebar component. |
| openedChange | `opened: boolean` | Emitted when `opened` is modified. This allows for you to do "two-way binding" (i.e. `[(opened)]`). |
| onOpenStart | | Emitted when the sidebar is opening. |
| onOpened | | Emitted when the sidebar is opened. |
Expand Down
10 changes: 8 additions & 2 deletions src/sidebar.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
AfterContentInit,
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
Expand Down Expand Up @@ -84,7 +85,7 @@ import { isLTR, isIOS } from './utils';
`],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class Sidebar implements OnInit, OnChanges, OnDestroy {
export class Sidebar implements AfterContentInit, OnInit, OnChanges, OnDestroy {
// `openedChange` allows for "2-way" data binding
@Input() opened: boolean = false;
@Output() openedChange: EventEmitter<boolean> = new EventEmitter<boolean>();
Expand Down Expand Up @@ -112,6 +113,7 @@ export class Sidebar implements OnInit, OnChanges, OnDestroy {
@Input() keyClose: boolean = false;
@Input() keyCode: number = 27; // Default to ESC key

@Output() onContentInit: EventEmitter<null> = new EventEmitter<null>();
@Output() onOpenStart: EventEmitter<null> = new EventEmitter<null>();
@Output() onOpened: EventEmitter<null> = new EventEmitter<null>();
@Output() onCloseStart: EventEmitter<null> = new EventEmitter<null>();
Expand Down Expand Up @@ -175,7 +177,7 @@ export class Sidebar implements OnInit, OnChanges, OnDestroy {
this._collapse = this._collapse.bind(this);
}

ngOnInit() {
ngOnInit(): void {
if (!this._isBrowser) {
return;
}
Expand All @@ -192,6 +194,10 @@ export class Sidebar implements OnInit, OnChanges, OnDestroy {
}
}

ngAfterContentInit(): void {
this.onContentInit.emit();
}

ngOnChanges(changes: SimpleChanges): void {
if (!this._isBrowser) {
return;
Expand Down

0 comments on commit 054d5ce

Please sign in to comment.