Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/ui-scroll.component.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import {
Component, OnInit, OnDestroy,
TemplateRef, ElementRef,
ChangeDetectionStrategy, ChangeDetectorRef
ChangeDetectionStrategy, ChangeDetectorRef,
ViewChild
} from '@angular/core';

import { Workflow } from './component/workflow';
import { Datasource as IDatasource } from './component/interfaces/index';
import { Datasource } from './component/classes/datasource';
import { Item } from './component/classes/item';

const template = `<ng-container *ngIf="isTable"><tr data-sid="backward">
const template = `<ng-container #uiScrollTemplateRef *ngIf="isTable"><tr data-sid="backward">
<td><div data-padding-backward></div></td>
</tr><ng-template
*ngFor="let item of items"
Expand All @@ -35,7 +36,7 @@ const template = `<ng-container *ngIf="isTable"><tr data-sid="backward">
odd: item.$index % 2,
even: !(item.$index % 2)
}"
></ng-template></div><div data-padding-forward></div></ng-container>`
></ng-template></div><div data-padding-forward></div></ng-container>`;

/* tslint:disable:component-selector */
@Component({
Expand All @@ -45,6 +46,9 @@ const template = `<ng-container *ngIf="isTable"><tr data-sid="backward">
})
export class UiScrollComponent implements OnInit, OnDestroy {

@ViewChild('uiScrollTemplateRef', { static: true })
public uiScrollTemplateRef: TemplateRef<any>;

// come from the directive
public version: string;
public template: TemplateRef<any>;
Expand Down
7 changes: 3 additions & 4 deletions src/ui-scroll.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,13 @@ export class UiScrollDirective implements OnInit {
}

ngOnInit() {
const templateView = this.templateRef.createEmbeddedView({});
const compFactory = this.resolver.resolveComponentFactory(UiScrollComponent);
const componentRef = this.viewContainer.createComponent(
compFactory, undefined, this.viewContainer.injector, [templateView.rootNodes]
);
const componentRef = compFactory.create(this.viewContainer.injector);
componentRef.instance.datasource = this.datasource;
componentRef.instance.template = this.templateRef;
componentRef.instance.isTable = this.isTable;
componentRef.instance.version = version;

this.viewContainer.createEmbeddedView(componentRef.instance.uiScrollTemplateRef);
}
}