There are three ways to do this:
- Put an
*ngIfin parent. Only render child when parent’sitemsis ready.
<div *ngIf="items">
<child [items]="items | async">
</div>
- Separate your input
gettersetterin child. Then act whenever the value is set, you can use RxJSBehaviorSubjectalso.
private _items = new BehaviorSubject<Items[]>([]);
@Input() set items(value: Items[]) {
this._items.next(value);
}
get items() {
return this._items.getValue();
}
ngOnInit() {
this._items.subscribe(x => {
this.chunk(x);
})
}
- Do it during the
ngOnChangesof the child. Refer to here for example. https://angular.io/docs/ts/latest/guide/lifecycle-hooks.html#!#onchanges