Skip to content

Commit e50b380

Browse files
author
Nedyalko Nikolov
committed
Fix ListView to work as a direct child of a Page.
1 parent 4bafb79 commit e50b380

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/nativescript-angular/directives/list-view-comp.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ import {
55
TemplateRef,
66
ContentChild,
77
AppViewManager,
8-
EmbeddedViewRef,
8+
EmbeddedViewRef,
9+
ViewContainerRef,
910
HostListener,
1011
IterableDiffers,
1112
IterableDiffer,
1213
ChangeDetectorRef,
1314
EventEmitter,
15+
ViewChild,
1416
Output} from 'angular2/core';
1517
import {isListLikeIterable} from 'angular2/src/facade/collection';
1618
import {Observable as RxObservable} from 'rxjs'
@@ -29,13 +31,18 @@ export interface SetupItemViewArgs {
2931

3032
@Component({
3133
selector: 'ListView',
32-
template: ``,
34+
template: `
35+
<DetachedContainer>
36+
<Placeholder #loader></Placeholder>
37+
</DetachedContainer>`,
3338
inputs: ['items']
3439
})
3540
export class ListViewComponent {
3641
private listView: ListView;
3742
private _items: any;
3843
private _differ: IterableDiffer;
44+
45+
@ViewChild('loader') public loader: ElementRef;
3946

4047
@Output() public setupItemView: EventEmitter<SetupItemViewArgs> = new EventEmitter<SetupItemViewArgs>();
4148

@@ -80,7 +87,7 @@ export class ListViewComponent {
8087
}
8188
else {
8289
console.log("ListView.onItemLoading: " + index + " - Creating view from template");
83-
viewRef = this._appViewManager.createEmbeddedViewInContainer(this._elementRef, index, this.itemTemplate);
90+
viewRef = this._appViewManager.createEmbeddedViewInContainer(this.loader, 0, this.itemTemplate);
8491
args.view = getSingleViewFromViewRef(viewRef);
8592
args.view[NG_VIEW] = viewRef;
8693
}

0 commit comments

Comments
 (0)