Skip to content

Commit

Permalink
fix(table): onComponentInit hook didn't called when OnInit didn't imp…
Browse files Browse the repository at this point in the history
…lemented
  • Loading branch information
tibing-old-email committed May 5, 2017
1 parent 2bb9bd8 commit 067a346
Showing 1 changed file with 1 addition and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class CustomViewComponent implements OnInit, OnDestroy {
ngOnInit() {
if (this.cell && !this.customComponent) {
this.createCustomComponent();
this.decorateNgOnInit();
this.callOnComponentInit();
this.patchInstance();
}
}
Expand All @@ -45,24 +45,11 @@ export class CustomViewComponent implements OnInit, OnDestroy {
this.customComponent = this.dynamicTarget.createComponent(componentFactory);
}

protected decorateNgOnInit() {
const baseInit = this.customComponent.instance.ngOnInit;

this.customComponent.instance.ngOnInit = () => {
this.callOnComponentInit();
this.callBaseInit(baseInit);
};
}

protected callOnComponentInit() {
const onComponentInitFunction = this.cell.getColumn().getOnComponentInitFunction();
onComponentInitFunction && onComponentInitFunction(this.customComponent.instance);
}

protected callBaseInit(baseInit: Function) {
baseInit && baseInit.call(this.customComponent.instance);
}

protected patchInstance() {
Object.assign(this.customComponent.instance, this.getPatch());
}
Expand Down

0 comments on commit 067a346

Please sign in to comment.