Skip to content

Instantly share code, notes, and snippets.

View maxkoretskyi's full-sized avatar

Max Koretskyi maxkoretskyi

View GitHub Profile
export class Ng2FrameworkComponentWrapper extends ... {
...
public createComponent<T>(componentType: { new(...args: any[]): T; }): ComponentRef<T> {
let factory = this.componentFactoryResolver.resolveComponentFactory(componentType);
return this.viewContainerRef.createComponent(factory);
}
}
class BaseGuiComponent {
protected init(params: P): void {
this._params = params;
this._componentRef = this.createComponent();
this._agAwareComponent = this._componentRef.instance;
this._frameworkComponentInstance = this._componentRef.instance;
this._eGui = this._componentRef.location.nativeElement;
this._agAwareComponent.agInit(this._params);
@Component({
selector: 'ag-grid-angular',
...
})
export class AgGridNg2 implements AfterViewInit {
...
constructor(private viewContainerRef: ViewContainerRef,
private frameworkComponentWrapper: Ng2FrameworkComponentWrapper,
private _componentFactoryResolver: ComponentFactoryResolver, ...) {
...
class BaseGuiComponent {
protected init(params: P): void { ... }
public getGui(): HTMLElement {
return this._eGui;
}
}
class BaseGuiComponent {
protected init(params: P): void {
this._params = params;
this._componentRef = this.createComponent();
this._agAwareComponent = this._componentRef.instance;
this._frameworkComponentInstance = this._componentRef.instance;
this._eGui = this._componentRef.location.nativeElement;
this._agAwareComponent.agInit(this._params);
class DynamicAgNg2Component extends BaseGuiComponent {
init(params) {
_super.prototype.init.call(this, params);
this._componentRef.changeDetectorRef.detectChanges();
};
...
}
class DynamicAgNg2Component extends BaseGuiComponent {
init(params) {
_super.prototype.init.call(this, params);
this._componentRef.changeDetectorRef.detectChanges();
};
...
}
class BaseGuiComponent {
protected init(params: P): void {
class BaseGuiComponent {
protected init(params: P): void {
this._params = params;
this._componentRef = this.createComponent();
this._agAwareComponent = this._componentRef.instance;
this._frameworkComponentInstance = this._componentRef.instance;
this._eGui = this._componentRef.location.nativeElement;
this._agAwareComponent.agInit(this._params);
@Component({
selector: 'app-number-formatter-cell',
template: `
<span>{{params.value | currency:'EUR'}}</span>
`
})
export class NumberFormatterComponent {
params: any;
agInit(params: any): void {
class NumberCellFormatter {
init(params) {
const text = params.value.toLocaleString(undefined, {style: 'currency', currency: 'EUR'});
this.eGui = document.createElement('span');
this.eGui.innerHTML = text;
}
getGui() {
return this.eGui;